perf(api): add HTTP range requests on media sources (#9)
All checks were successful
CI / Maven unit tests (push) Successful in 20s
CI / Build and push images (push) Successful in 5m14s
CI / Deploy to server (push) Successful in 1m29s

Reviewed-on: https://gitea.vodsystem.ddns.net/dylan/vod-system/pulls/9
This commit was merged in pull request #9.
This commit is contained in:
2026-07-25 11:06:39 +01:00
parent 74a9d5752d
commit ae8f2f33a7
18 changed files with 1963 additions and 1447 deletions

View File

@@ -156,6 +156,10 @@ public class ClipService {
throw new ClipNotFound("Clip file not found");
}
if (!Files.isReadable(file)) {
throw new ClipMediaUnavailable(id, "Clip file is not readable");
}
return new FileSystemResource(file);
}

View File

@@ -10,6 +10,7 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import java.util.stream.Stream;
import java.nio.file.StandardCopyOption;
@@ -129,11 +130,29 @@ public class DirectoryService {
}
}
private void checkDirPermissions() {
List<Path> dirs = List.of(
Path.of(tempInputsDir),
Path.of(tempOutputsDir),
Path.of(usersDir)
);
List<Path> bad = dirs.stream()
.filter(p -> !Files.isDirectory(p) || !Files.isReadable(p) || !Files.isWritable(p))
.toList();
if (!bad.isEmpty()) {
throw new IllegalStateException("Unusable directories: " + bad);
}
}
@PostConstruct
public void createDirectoriesIfNotExist() throws IOException {
Files.createDirectories(Path.of(tempInputsDir));
Files.createDirectories(Path.of(tempOutputsDir));
Files.createDirectories(Path.of(usersDir));
checkDirPermissions();
}
@Scheduled(fixedRate = TEMP_DIR_CLEANUP_RATE)

View File

@@ -93,7 +93,7 @@ public class MediaService {
);
}).exceptionally(ex -> {
job.setState(JobState.FAILED);
job.setErrorOutput(ex.getMessage());
job.setErrorOutput("Compression job failed");
logger.error("Compression job with UUID {} failed due to: {}", job.getUuid(), ex.getMessage());
return null;
});

View File

@@ -139,6 +139,10 @@ public class VodService {
throw new VodNotFound("Vod file not found for ID: " + id);
}
if (!Files.isReadable(file)) {
throw new VodMediaUnavailable(id, "Vod file is not readable");
}
return new FileSystemResource(file);
}