|
|
@ -60,7 +60,7 @@ impl Repository {
|
|
|
|
match fs::copy(&ingest_file, &archive_file) {
|
|
|
|
match fs::copy(&ingest_file, &archive_file) {
|
|
|
|
Ok(_) => {
|
|
|
|
Ok(_) => {
|
|
|
|
info!("Archiving video file {}.", ingest_file.to_str().unwrap());
|
|
|
|
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) => {
|
|
|
|
Err(e) => {
|
|
|
|
error!("Error archiving file {}: {}", ingest_file.to_str().unwrap(), 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
|
|
|
|
// grab old file metadata
|
|
|
|
let old_metadata = fs::metadata(old_file).unwrap();
|
|
|
|
let old_metadata = fs::metadata(old_file).unwrap();
|
|
|
|
|
|
|
|
let old_permissions = old_metadata.permissions();
|
|
|
|
let mtime = FileTime::from_last_modification_time(&old_metadata);
|
|
|
|
let mtime = FileTime::from_last_modification_time(&old_metadata);
|
|
|
|
let atime = FileTime::from_last_access_time(&old_metadata);
|
|
|
|
let atime = FileTime::from_last_access_time(&old_metadata);
|
|
|
|
|
|
|
|
|
|
|
|
// set metadata on the new file
|
|
|
|
// set metadata on the new file
|
|
|
|
let new_path = Path::new(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.");
|
|
|
|
filetime::set_file_times(new_path, atime, mtime).expect("Failed to set atime and mtime.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|