Clippy
This commit is contained in:
@ -43,7 +43,6 @@ use_debug = "allow"
|
|||||||
verbose_file_reads = "deny"
|
verbose_file_reads = "deny"
|
||||||
large_types_passed_by_value = "deny"
|
large_types_passed_by_value = "deny"
|
||||||
large_enum_variant = "allow"
|
large_enum_variant = "allow"
|
||||||
match_on_vec_items = "deny"
|
|
||||||
wildcard_dependencies = "deny"
|
wildcard_dependencies = "deny"
|
||||||
negative_feature_names = "deny"
|
negative_feature_names = "deny"
|
||||||
redundant_feature_names = "deny"
|
redundant_feature_names = "deny"
|
||||||
|
@ -88,6 +88,7 @@ fn main_inner() -> Result<ExitCode> {
|
|||||||
let max_tasks = manifest.config.threads.map(|x| x.get()).unwrap_or(1);
|
let max_tasks = manifest.config.threads.map(|x| x.get()).unwrap_or(1);
|
||||||
|
|
||||||
debug!("Starting runtime with {max_tasks} threads");
|
debug!("Starting runtime with {max_tasks} threads");
|
||||||
|
#[expect(clippy::unwrap_used)]
|
||||||
let rt = tokio::runtime::Builder::new_multi_thread()
|
let rt = tokio::runtime::Builder::new_multi_thread()
|
||||||
.worker_threads(3)
|
.worker_threads(3)
|
||||||
.max_blocking_threads(max_tasks)
|
.max_blocking_threads(max_tasks)
|
||||||
@ -116,12 +117,13 @@ fn main_inner() -> Result<ExitCode> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if js.len() >= max_tasks {
|
if js.len() >= max_tasks {
|
||||||
|
#[expect(clippy::unwrap_used)]
|
||||||
js.join_next().await.unwrap()??;
|
js.join_next().await.unwrap()??;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while let Some(x) = js.join_next().await {
|
while let Some(x) = js.join_next().await {
|
||||||
x.unwrap()?
|
x??
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok::<_, Error>(());
|
return Ok::<_, Error>(());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use anyhow::{Result, bail};
|
use anyhow::{bail, Result};
|
||||||
use regex::Regex;
|
use regex::Regex;
|
||||||
use tracing::warn;
|
use tracing::warn;
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ impl Iterator for PickRuleIterator<'_> {
|
|||||||
match value {
|
match value {
|
||||||
PickRule::Plain(task) => {
|
PickRule::Plain(task) => {
|
||||||
let mut patterns = current.prefix.clone();
|
let mut patterns = current.prefix.clone();
|
||||||
patterns.push(key.to_string());
|
patterns.push(key.to_owned());
|
||||||
|
|
||||||
Some(FlatPickRule {
|
Some(FlatPickRule {
|
||||||
patterns,
|
patterns,
|
||||||
@ -199,7 +199,7 @@ impl Iterator for PickRuleIterator<'_> {
|
|||||||
}
|
}
|
||||||
PickRule::Nested(nested_rules) => {
|
PickRule::Nested(nested_rules) => {
|
||||||
let mut prefix = current.prefix.clone();
|
let mut prefix = current.prefix.clone();
|
||||||
prefix.push(key.to_string());
|
prefix.push(key.to_owned());
|
||||||
|
|
||||||
self.stack.push(PickRuleIterState {
|
self.stack.push(PickRuleIterState {
|
||||||
rules: nested_rules,
|
rules: nested_rules,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use anyhow::{Context, Result, bail};
|
use anyhow::{bail, Context, Result};
|
||||||
use indicatif::ProgressBar;
|
use indicatif::ProgressBar;
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
@ -7,7 +7,7 @@ use std::{
|
|||||||
use tracing::{error, trace};
|
use tracing::{error, trace};
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
use crate::{Cli, manifest::types::Manifest, style::spinner_style_list, tool::TaskContext};
|
use crate::{manifest::types::Manifest, style::spinner_style_list, tool::TaskContext, Cli};
|
||||||
|
|
||||||
pub fn load_manifest(cli: &Cli) -> Result<Manifest> {
|
pub fn load_manifest(cli: &Cli) -> Result<Manifest> {
|
||||||
let manifest_path_str = cli
|
let manifest_path_str = cli
|
||||||
|
@ -34,7 +34,7 @@ impl PickTool for ToolBash {
|
|||||||
debug!("Running `before` script");
|
debug!("Running `before` script");
|
||||||
let mut temp_file =
|
let mut temp_file =
|
||||||
tempfile::NamedTempFile::new().context("while creating temporary script")?;
|
tempfile::NamedTempFile::new().context("while creating temporary script")?;
|
||||||
writeln!(temp_file, "{}", script).context("while creating temporary script")?;
|
writeln!(temp_file, "{script}").context("while creating temporary script")?;
|
||||||
temp_file
|
temp_file
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -82,7 +82,7 @@ impl PickTool for ToolBash {
|
|||||||
debug!("Running `after` script");
|
debug!("Running `after` script");
|
||||||
let mut temp_file =
|
let mut temp_file =
|
||||||
tempfile::NamedTempFile::new().context("while creating temporary script")?;
|
tempfile::NamedTempFile::new().context("while creating temporary script")?;
|
||||||
writeln!(temp_file, "{}", script).context("while creating temporary script")?;
|
writeln!(temp_file, "{script}").context("while creating temporary script")?;
|
||||||
temp_file
|
temp_file
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -131,7 +131,7 @@ impl PickTool for ToolBash {
|
|||||||
trace!("Running script for {}: {}", ctx.path_rel_str, ctx.task);
|
trace!("Running script for {}: {}", ctx.path_rel_str, ctx.task);
|
||||||
let mut temp_file =
|
let mut temp_file =
|
||||||
tempfile::NamedTempFile::new().context("while creating temporary script")?;
|
tempfile::NamedTempFile::new().context("while creating temporary script")?;
|
||||||
writeln!(temp_file, "{}", script).context("while creating temporary script")?;
|
writeln!(temp_file, "{script}").context("while creating temporary script")?;
|
||||||
temp_file
|
temp_file
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
109
test.toml
Normal file
109
test.toml
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
[config]
|
||||||
|
work_dir = "/mnt/hdd/media/Media/Music/Library"
|
||||||
|
|
||||||
|
[tool.bash]
|
||||||
|
env.TARGET = "/home/mark/out"
|
||||||
|
|
||||||
|
before = """
|
||||||
|
rm -drf ${TARGET}
|
||||||
|
"""
|
||||||
|
|
||||||
|
script.mp3 = """
|
||||||
|
mkdir -p "$(dirname "${TARGET}/${PICK_RELATIVE}")"
|
||||||
|
|
||||||
|
filename="${PICK_RELATIVE%.*}"
|
||||||
|
|
||||||
|
ffmpeg \
|
||||||
|
-i "${PICK_FILE}" \
|
||||||
|
-map_metadata 0 \
|
||||||
|
-id3v2_version 3 \
|
||||||
|
-b:a 192k \
|
||||||
|
-loglevel error \
|
||||||
|
-hide_banner -n \
|
||||||
|
"${TARGET}/${filename}.mp3"
|
||||||
|
"""
|
||||||
|
|
||||||
|
script.ogg = """
|
||||||
|
mkdir -p "$(dirname "${TARGET}/${PICK_RELATIVE}")"
|
||||||
|
|
||||||
|
filename="${PICK_RELATIVE%.*}"
|
||||||
|
|
||||||
|
ffmpeg \
|
||||||
|
-i "${PICK_FILE}" \
|
||||||
|
-c:v libtheora \
|
||||||
|
-q:v 10 \
|
||||||
|
-c:a libopus \
|
||||||
|
-b:a 192k \
|
||||||
|
-loglevel error \
|
||||||
|
-hide_banner -n \
|
||||||
|
"${TARGET}/${filename}.ogg"
|
||||||
|
"""
|
||||||
|
|
||||||
|
script.raw = """
|
||||||
|
mkdir -p "$(dirname "${TARGET}/${PICK_RELATIVE}")"
|
||||||
|
cp "${PICK_FILE}" "${TARGET}/${PICK_RELATIVE}"
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
|
# The first rule to match a path is run.
|
||||||
|
# Paths are checked relative to source.
|
||||||
|
# "/source/path/to/file.gz" becomes "path/to/file.gz"
|
||||||
|
#
|
||||||
|
# a "path segment" is a single file or directory.
|
||||||
|
#
|
||||||
|
# * matches exactly one path segment. In regex, this is [^/]+
|
||||||
|
# ** matches zero or more path segments. In regex, this is ([^/]+)*
|
||||||
|
#
|
||||||
|
# All rules are matched against the FULL PATH of files.
|
||||||
|
# Directories are ignored.
|
||||||
|
[[rules]]
|
||||||
|
"Classical/**" = ""
|
||||||
|
"Holiday/**" = ""
|
||||||
|
"Rock/**" = ""
|
||||||
|
"Electro-Swing/**" = ""
|
||||||
|
"Score/**" = ""
|
||||||
|
"Country/**" = ""
|
||||||
|
"Instrument/**" = ""
|
||||||
|
"Lofi Rip/**" = "raw"
|
||||||
|
|
||||||
|
|
||||||
|
[[rules."Ru"]]
|
||||||
|
"The Alexandrov Red Army Chorus/**" = "raw"
|
||||||
|
"Алиса/**" = "raw"
|
||||||
|
"Андрей Губин/**" = "raw"
|
||||||
|
"Баста/**" = "raw"
|
||||||
|
"Виктор Цой/**" = "raw"
|
||||||
|
"Денис Майданов/**" = "raw"
|
||||||
|
"дора/**" = "raw"
|
||||||
|
"Игорь Растеряев/**" = "raw"
|
||||||
|
"Иосиф Кобзон/**" = "raw"
|
||||||
|
"Кино/**" = "raw"
|
||||||
|
"Лев Лещенко/**" = "raw"
|
||||||
|
"Любэ/**" = "raw"
|
||||||
|
"Марк Бернес/**" = "raw"
|
||||||
|
"Муслим Магомаев/**" = "raw"
|
||||||
|
"Отава Ё/**" = "raw"
|
||||||
|
"**" = ""
|
||||||
|
|
||||||
|
[[rules."Pop"]]
|
||||||
|
"5 Seconds Of Summer/**" = "mp3"
|
||||||
|
"Andy Grammer/**" = "raw"
|
||||||
|
"Christina Perri/**" = "raw"
|
||||||
|
"Club Danger/**" = "raw"
|
||||||
|
"Colbie Caillat/**" = "raw"
|
||||||
|
"Echosmith/**" = "raw"
|
||||||
|
"Future Royalty/**" = "raw"
|
||||||
|
"Imagine Dragons/**" = "raw"
|
||||||
|
"Kate Voegele/**" = "raw"
|
||||||
|
"NEFFEX/**" = "raw"
|
||||||
|
"NewJeans/**" = "raw"
|
||||||
|
"Niall Horan/**" = "raw"
|
||||||
|
"Of Monsters and Men/**" = "raw"
|
||||||
|
"Oh The Larceny/**" = "raw"
|
||||||
|
"OneRepublic/**" = "raw"
|
||||||
|
"Outskrts/**" = "raw"
|
||||||
|
"Paramore/**" = "raw"
|
||||||
|
"Taylor Swift/**" = "raw"
|
||||||
|
"The Score/**" = "raw"
|
||||||
|
"The Seige/**" = "raw"
|
||||||
|
"**" = ""
|
Reference in New Issue
Block a user