forked from j62/ctbrec
1
0
Fork 0

Make loading of recording meta data more robust

This commit is contained in:
0xboobface 2019-07-21 11:23:10 +02:00
parent e39ff8d7d4
commit 2131b596cb
1 changed files with 13 additions and 9 deletions

View File

@ -71,15 +71,19 @@ public class RecordingManager {
if (metaFiles != null) {
for (File file : metaFiles) {
String json = new String(Files.readAllBytes(file.toPath()), "utf-8");
Recording recording = adapter.fromJson(json);
if (recording.getStatus() == State.RECORDING) {
recording.setStatus(State.WAITING);
}
if (recordingExists(recording)) {
recordings.add(recording);
} else {
LOG.info("Recording {} does not exist anymore -> deleting meta data", recording);
Files.deleteIfExists(file.toPath());
try {
Recording recording = adapter.fromJson(json);
if (recording.getStatus() == State.RECORDING) {
recording.setStatus(State.WAITING);
}
if (recordingExists(recording)) {
recordings.add(recording);
} else {
LOG.info("Recording {} does not exist anymore -> deleting meta data", recording);
Files.deleteIfExists(file.toPath());
}
} catch(Exception e) {
LOG.error("Couldn't load recording {}", file, e);
}
}
}