A tool to sync music with your favorite devices
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

*: make the update command actually work

TODO: need to make sure update removes tracks that aren't present
anymore

Gee Sawra e8c36a54 f86b4ddd

+27 -3
+1 -1
src/cli.rs
··· 22 22 Dupes(cmd::dupes::Args), 23 23 24 24 /// Updates the local database with new tracks from previously added directories. 25 - Update(cmd::add::Args), 25 + Update(cmd::update::Args), 26 26 27 27 /// Cleans destination of uncleanly-copied files. 28 28 Clean(cmd::clean::Args),
+1
src/cmd/mod.rs
··· 6 6 pub mod ipod_init; 7 7 pub mod sync; 8 8 pub mod transcode; 9 + pub mod update;
+23
src/cmd/update.rs
··· 1 + use crate::*; 2 + use anyhow::{Context, Result}; 3 + use clap::Args as ClapArgs; 4 + 5 + #[derive(ClapArgs, Debug)] 6 + pub struct Args { 7 + /// Directory in which tunz will store its local database. 8 + #[arg(short, long, default_value_t = db::default_database_dir().to_str().unwrap().to_owned())] 9 + pub database_path: String, 10 + } 11 + 12 + pub async fn run(args: Args) -> Result<()> { 13 + log::debug!("CLI args: {:?}", args); 14 + 15 + // Open a database 16 + let db = db::Instance::new(&args.database_path, false) 17 + .await 18 + .with_context(|| "Cannot open local database instance")?; 19 + 20 + let totals = library::update(&db, |_| {}).await?; 21 + log::info!("Imported {} tracks", totals.0); 22 + Ok(()) 23 + }
+1 -1
src/db/instance.rs
··· 413 413 pub async fn track_paths_from_dir(&self, directory: String) -> Result<Vec<String>, Error> { 414 414 let mut conn = self.pool.acquire().await?; 415 415 416 - let directory = format!("{}?", directory); 416 + let directory = format!("{}%", directory); 417 417 Ok(sqlx::query!( 418 418 r#"SELECT file_path FROM tracks where file_path LIKE ?1"#, 419 419 directory,
+1 -1
src/main.rs
··· 30 30 cli::Commands::Add(add_args) => Ok(cmd::add::run(add_args, false).await?), 31 31 cli::Commands::Dupes(dupes_args) => Ok(cmd::dupes::run(dupes_args).await?), 32 32 cli::Commands::Clean(clean_args) => Ok(cmd::clean::run(clean_args).await?), 33 - cli::Commands::Update(update_args) => Ok(cmd::add::run(update_args, true).await?), 33 + cli::Commands::Update(update_args) => Ok(cmd::update::run(update_args).await?), 34 34 cli::Commands::Settings { command } => match command { 35 35 cli::Settings::Filter(args) => Ok(cmd::filter::run(args).await?), 36 36 cli::Settings::Transcode(args) => Ok(cmd::transcode::run(args).await?),