Change from dbfile to dbdir, dbfile is now dbdir/dbfile

- add autosave 1 minute after change is made to db 1 minute
- improved gapless playback (used to run some code 10 times a second for gapless playback, is now event driven)
- saving now moves the previous file to dbfile-[UNIX-TIMESTAMP] in case something goes wrong when saving the new dbfile.
This commit is contained in:
Mark
2024-01-10 14:05:22 +01:00
parent 8a9ee5c9cf
commit 6f9535a28e
4 changed files with 126 additions and 39 deletions

View File

@@ -15,13 +15,13 @@ use musicdb_lib::data::database::Database;
#[derive(Parser, Debug)]
struct Args {
/// The file which contains information about the songs in your library
/// The directory which contains information about the songs in your library
#[arg()]
dbfile: PathBuf,
db_dir: PathBuf,
/// The path containing your actual library.
#[arg()]
lib_dir: PathBuf,
/// skip reading the `dbfile` (because it doesn't exist yet)
/// skip reading the dbfile (because it doesn't exist yet)
#[arg(long)]
init: bool,
/// optional address for tcp connections to the server
@@ -42,13 +42,13 @@ async fn main() {
// parse args
let args = Args::parse();
let mut database = if args.init {
Database::new_empty(args.dbfile, args.lib_dir)
Database::new_empty_in_dir(args.db_dir, args.lib_dir)
} else {
match Database::load_database(args.dbfile.clone(), args.lib_dir.clone()) {
match Database::load_database_from_dir(args.db_dir.clone(), args.lib_dir.clone()) {
Ok(db) => db,
Err(e) => {
eprintln!("Couldn't load database!");
eprintln!(" dbfile: {:?}", args.dbfile);
eprintln!(" dbfile: {:?}", args.db_dir);
eprintln!(" libdir: {:?}", args.lib_dir);
eprintln!(" err: {}", e);
exit(1);