Skip to content

Commit

Permalink
Fix parsing of argument --positions-restore
Browse files Browse the repository at this point in the history
  • Loading branch information
izderadicka committed Jan 1, 2025
1 parent 62e570a commit 91d7e78
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "audioserve"
version = "0.28.12"
version = "0.28.13"
authors = ["Ivan <[email protected]>"]
edition = "2021"
rust-version = "1.72"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ Proper functioning is (indeed) dependent on good connectivity - as position is s

Position tracking is tightly connected with collection cache, so it'll not work for collection, which do not use caching (specified with `:no-cache` option). You can also backup positions to JSON file (highly recommended) for restoration in case of disk problems or for migration of audioserve - check `--positions-backup-file` and `--positions-backup-schedule` arguments of the program. Also if former argument is present you can force immediate backup by sending signal `sigusr2` to the program.

To restore from positions backup run audioserve once with `--positions-restore=v1` and `--positions-backup-file` arguments and collections paths (ensure before that collections are scanned fully), it will finish immediately after restoring positions, then run it again with your usual arguments.

Shared playback positions are behind default program feature `shared-positions`, so you can compile program without it.

Shared positions also serve for marking finished / listened folders - if last file in the folder is listened till some offset from it's end (configurable via option `time-to-folder-end`, defaults to 10 seconds), folder if then marked as finished. If you start listening the folder again it is unmarked - folder finished flag is derived directly of last listening position in this folder.
Expand Down
2 changes: 1 addition & 1 deletion src/config/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ fn create_parser() -> Command {
.arg(
long_arg!(AUDIOSERVE_POSITIONS_RESTORE)
.num_args(1)
.value_parser(["legacy", "v1"])
.value_parser(positions_restore_format)
.requires(AUDIOSERVE_POSITIONS_BACKUP_FILE)
.help("Restores positions from backup JSON file, value is version of file legacy is before audioserve v0.16, v1 is current")
)
Expand Down
8 changes: 8 additions & 0 deletions src/config/validators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use std::{
time::Duration,
};

use super::PositionsBackupFormat;

pub fn is_existing_dir(p: &str) -> Result<PathBuf, anyhow::Error> {
let p = Path::new(p);
if !p.is_dir() {
Expand Down Expand Up @@ -44,3 +46,9 @@ pub fn duration_secs(s: &str) -> Result<Duration, anyhow::Error> {
let secs: u64 = s.parse().context("Invalid Duration")?;
Ok(Duration::from_secs(secs))
}

pub fn positions_restore_format(s: &str) -> Result<PositionsBackupFormat, anyhow::Error> {
let format: PositionsBackupFormat =
s.parse().context(format!("Invalid format string {}", s))?;
Ok(format)
}

0 comments on commit 91d7e78

Please sign in to comment.