Added ability for the transcoder to determine if a video file is open in another program to avoid trying to transcode/remove a partially written file; reworked the main transcode loop to handle one file at a time instead of archiving everything, then transcoding, then cleanup
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/tag/woodpecker Pipeline failed

This commit is contained in:
2022-05-20 07:58:52 -04:00
parent fe29664a83
commit 5bc2acac1d
5 changed files with 110 additions and 57 deletions

View File

@ -1,15 +1,21 @@
package tech.bitgoblin.io;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
public class IOUtilsTest {
private static String testDir = "test-temp";
private static String testFile = "test.txt";
@Test
public void shouldCreateDirectory() {
@ -28,9 +34,30 @@ public class IOUtilsTest {
IOUtils.resolveTilda("~test");
}
@Test
public void fileShouldBeLocked() throws IOException {
RandomAccessFile raf = new RandomAccessFile(testFile, "rw");
assertTrue(IOUtils.isFileLocked(new File(testFile)));
}
@Test
public void fileShouldNotBeLocked() throws IOException {
RandomAccessFile raf = new RandomAccessFile("test.txt", "rw");
raf.close();
assertFalse(IOUtils.isFileLocked(new File(testFile)));
}
@BeforeClass
// ensure that test files are created before running tests
public static void setup() throws IOException {
new File(testFile).createNewFile();
}
@AfterClass
// ensure test files are cleaned up from the environment
public static void cleanup() {
new File(testDir).delete();
new File(testFile).delete();
}
}