diff --git a/src/main/java/tech/bitgoblin/transcoder/Repository.java b/src/main/java/tech/bitgoblin/transcoder/Repository.java index 8fe28ba..128c1ae 100644 --- a/src/main/java/tech/bitgoblin/transcoder/Repository.java +++ b/src/main/java/tech/bitgoblin/transcoder/Repository.java @@ -40,10 +40,7 @@ public class Repository { } // archives files in the ingest directory - public void archiveIngest() { - File repo = new File(this.archivePath); - File[] sourceFiles = repo.listFiles(); - + public void archiveIngest(File[] sourceFiles) { for (File f : sourceFiles) { Path filePath = Path.of(f.toString()); String filename = filePath.getFileName().toString(); @@ -58,10 +55,7 @@ public class Repository { } // clean up the ingest directory once we're done - public void cleanupIngest() { - File repo = new File(this.ingestPath); - File[] sourceFiles = repo.listFiles(); - + public void cleanupIngest(File[] sourceFiles) { for (File f : sourceFiles) { f.delete(); } diff --git a/src/main/java/tech/bitgoblin/transcoder/Transcoder.java b/src/main/java/tech/bitgoblin/transcoder/Transcoder.java index 987df64..4474e0b 100644 --- a/src/main/java/tech/bitgoblin/transcoder/Transcoder.java +++ b/src/main/java/tech/bitgoblin/transcoder/Transcoder.java @@ -32,19 +32,19 @@ public class Transcoder { // create a periodic timer task and start it public void run() { - // save source video files - this.repo.archiveIngest(); - // transcode video files to new format - this.transcode(); - // cleanup old video files in ingest - this.repo.cleanupIngest(); + // pull list of files to transcode + File[] sourceFiles = this.repo.searchIngest(); + + // archive files + this.repo.archiveIngest(sourceFiles); + // transcode files + this.transcode(sourceFiles); + // cleanup old files + this.repo.cleanupIngest(sourceFiles); } // transcode files in the working directory - public void transcode() { - // search for files - File[] sourceFiles = this.repo.searchIngest(); - + public void transcode(File[] sourceFiles) { // check if the ingest directory is empty if (sourceFiles.length == 0) { Logger.logger.info("There is nothing to transcode in ingest.");