Added functionality to clean up transcoded source files

This commit is contained in:
Gregory Ballantine 2022-08-31 18:17:13 -04:00
parent b979850582
commit 32ffcdf202
2 changed files with 16 additions and 4 deletions

View File

@ -47,9 +47,9 @@ impl Repository {
return ingest_files;
}
pub fn archive_file(&self, file: String) {
let ingest_file = Path::new(&self.ingest_dir).join(&file);
let archive_file = Path::new(&self.archive_dir).join(&file);
pub fn archive_file(&self, file: &str) {
let ingest_file = Path::new(&self.ingest_dir).join(file);
let archive_file = Path::new(&self.archive_dir).join(file);
match fs::copy(&ingest_file, &archive_file) {
Ok(_) => {
@ -61,6 +61,12 @@ impl Repository {
}
}
}
pub fn cleanup_file(&self, file: &str) {
let ingest_file = Path::new(&self.ingest_dir).join(file);
fs::remove_file(&ingest_file)
.expect("File deletion failed.");
}
}
fn create_directory(path: &str) {

View File

@ -22,7 +22,13 @@ impl Transcoder {
for i in ingest_files {
// copy the file to the archive
self.repository.archive_file(i);
self.repository.archive_file(&i);
// perform the video transcode
// TODO - self.transcode(i);
// remove the source file
self.repository.cleanup_file(&i);
}
}
}