Skip to content

Commit

Permalink
small housekeeping changes
Browse files Browse the repository at this point in the history
  • Loading branch information
FerrahWolfeh committed Aug 18, 2023
1 parent f3eec9a commit ec04ce5
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ avif-serialize = "0.8.1"
notify-rust = { version = "4.8.0", features = ["images"] }
thread-priority = "0.13.1"
notify = "6.0.1"

[profile.release]
lto = false
opt-level = 3
Expand Down
2 changes: 1 addition & 1 deletion PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pkgname=avif-converter-git
pkgver=1.9.1
pkgver=1.10.1
pkgrel=1
source=("git+https://github.com/FerrahWolfeh/avif-converter.git")
sha256sums=('SKIP')
Expand Down
6 changes: 3 additions & 3 deletions services/aviffolder.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ X-KDE-Submenu=AVIF
[Desktop Action avif-custom]
Name=AVIF
Icon=image
Exec=File=%u ; avif-converter -N --quiet -q 80 -s 2 "$File"
Exec=File=%u ; avif-converter avif -N --quiet -q 80 -s 2 "$File"

[Desktop Action avif-preserve]
Name=AVIF (keep old files)
Icon=image
Exec=File=%u ; avif-converter -N --quiet -q 80 -s 2 -k "$File"
Exec=File=%u ; avif-converter avif -N --quiet -q 80 -s 2 -k "$File"

[Desktop Action avif-name]
Name=AVIF (keep names)
Icon=image
Exec=File=%u ; avif-converter -N --quiet -q 80 -s 2 -n same "$File"
Exec=File=%u ; avif-converter avif -N --quiet -q 80 -s 2 -n same "$File"
6 changes: 3 additions & 3 deletions src/cli/commands/watch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{
};
use threadpool::ThreadPool;

use crate::{cli::Args as Globals, image_file::ImageFile, utils::sys_threads};
use crate::{cli::Args as Globals, image_file::ImageFile, utils::{sys_threads, truncate_str}};
use clap::Args;

#[derive(Args, Debug, Clone)]
Expand Down Expand Up @@ -82,8 +82,8 @@ impl Watch {
image.save_avif(None, globals.name_type, globals.keep)?;

info!(
"File '{:.32}' encode finished. {} -> {} ({:?})",
image.metadata.filename,
"File '{}' encode finished. {} -> {} ({:?})",
truncate_str(&image.metadata.filename, 32),
ByteSize::b(image_size).to_string_as(true),
ByteSize::b(fsz).to_string_as(true),
start.elapsed()
Expand Down
12 changes: 12 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,15 @@ pub fn calculate_tread_count(num_threads: usize, num_items: usize) -> ThreadCoun
spawn_threads: sel_thread_count,
}
}

pub fn truncate_str(str: &str, size: usize) -> String {
assert!(str.len() > 3);

if str.len() <= size {
return str.to_string()
}

let mut truncated = str[..size].to_string();
truncated.push_str("...");
truncated
}

0 comments on commit ec04ce5

Please sign in to comment.