diff --git a/Cargo.toml b/Cargo.toml index 122214a..de1bf88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "zealot" description = "Bit Goblin automated video transcoding service." -version = "0.2.3" +version = "0.2.4" edition = "2021" readme = "README.md" license = "BSD 2-Clause" diff --git a/src/transcoder/repository.rs b/src/transcoder/repository.rs index 9b0c325..98fc899 100644 --- a/src/transcoder/repository.rs +++ b/src/transcoder/repository.rs @@ -60,7 +60,7 @@ impl Repository { match fs::copy(&ingest_file, &archive_file) { Ok(_) => { info!("Archiving video file {}.", ingest_file.to_str().unwrap()); - copy_file_times(ingest_file.to_str().unwrap(), archive_file.to_str().unwrap()); + copy_file_metadata(ingest_file.to_str().unwrap(), archive_file.to_str().unwrap()); }, Err(e) => { error!("Error archiving file {}: {}", ingest_file.to_str().unwrap(), e); @@ -93,13 +93,15 @@ fn create_directory(path: &str) { } } -fn copy_file_times(old_file: &str, new_file: &str) { +fn copy_file_metadata(old_file: &str, new_file: &str) { // grab old file metadata let old_metadata = fs::metadata(old_file).unwrap(); + let old_permissions = old_metadata.permissions(); let mtime = FileTime::from_last_modification_time(&old_metadata); let atime = FileTime::from_last_access_time(&old_metadata); // set metadata on the new file let new_path = Path::new(new_file); + fs::set_permissions(new_file, old_permissions).expect("Failed to set new file permissions."); filetime::set_file_times(new_path, atime, mtime).expect("Failed to set atime and mtime."); }