Ignore empty recordings directories
This commit is contained in:
parent
c57e0c037c
commit
cd827a0cb8
|
@ -368,8 +368,10 @@ public class LocalRecorder implements Recorder {
|
|||
PlaylistGenerator playlistGenerator = new PlaylistGenerator();
|
||||
playlistGenerators.put(recDir, playlistGenerator);
|
||||
try {
|
||||
playlistGenerator.generate(recDir);
|
||||
playlistGenerator.validate(recDir);
|
||||
File playlist = playlistGenerator.generate(recDir);
|
||||
if(playlist != null) {
|
||||
playlistGenerator.validate(recDir);
|
||||
}
|
||||
} catch (IOException | ParseException | PlaylistException e) {
|
||||
LOG.error("Couldn't generate playlist file", e);
|
||||
} catch (InvalidPlaylistException e) {
|
||||
|
@ -476,11 +478,18 @@ public class LocalRecorder implements Recorder {
|
|||
}
|
||||
|
||||
for (File subdir : subdirs) {
|
||||
// only consider directories
|
||||
if (!subdir.isDirectory()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore empty directories
|
||||
File[] recordingsDirs = subdir.listFiles();
|
||||
if(recordingsDirs.length == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// start going over valid directories
|
||||
for (File rec : recordingsDirs) {
|
||||
String pattern = "yyyy-MM-dd_HH-mm";
|
||||
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
|
||||
|
|
|
@ -44,10 +44,15 @@ public class PlaylistGenerator {
|
|||
private int lastPercentage;
|
||||
private List<ProgressListener> listeners = new ArrayList<>();
|
||||
|
||||
public void generate(File directory) throws IOException, ParseException, PlaylistException {
|
||||
public File generate(File directory) throws IOException, ParseException, PlaylistException {
|
||||
LOG.debug("Starting playlist generation for {}", directory);
|
||||
// get a list of all ts files and sort them by sequence
|
||||
File[] files = directory.listFiles((f) -> f.getName().endsWith(".ts"));
|
||||
if(files.length == 0) {
|
||||
LOG.debug("{} is empty. Not going to generate a playlist", directory);
|
||||
return null;
|
||||
}
|
||||
|
||||
Arrays.sort(files, (f1, f2) -> {
|
||||
String n1 = f1.getName();
|
||||
n1 = n1.substring(0, n1.length()-3);
|
||||
|
@ -107,6 +112,7 @@ public class PlaylistGenerator {
|
|||
writer.write(master);
|
||||
LOG.debug("Finished playlist generation for {}", directory);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
private void updateProgressListeners(double percentage) {
|
||||
|
|
Loading…
Reference in New Issue