Skip to content

Commit

Permalink
fix: lock before upload to ensure only one client is uploading at once
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrutchf committed Dec 12, 2024
1 parent 152eacd commit 80d639b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/subcommands/main_subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ impl CustomTransferAgent for MainSubcommand {
info!("Attempting to compress the source file.");
let compressed_source_path = self.compress_file(&event_source_path).await?;

// This is a System wide, cross-process lock.
// This is done to improve stability. We may be able to have more than one process
// in this method at a time, but it is unknown how many before we overwhelm the NAS and get a broken connection.
let lock = NamedLock::create("git-lfs-synology::MainSubcommand::upload")?;
let _guard = lock.lock()?;

let source_path = Path::new(&compressed_source_path);
let file_station = self.file_station.clone().context("File Station should not be null")?;
file_station.upload(source_path, event.size.context("Size should not be null")?, configuration.path.as_str(), false, false, None, None, None, Some(progress_reporter)).await?;
Expand Down

0 comments on commit 80d639b

Please sign in to comment.