Remove exludes from delete method

The excludes is not used anymore, since the whole merging mechanism
has been removed.

Add more debug statements for the different delete statements.
This commit is contained in:
0xboobface 2018-09-09 14:40:08 +02:00
parent 1c5bcaef35
commit d0a28aee2f
1 changed files with 9 additions and 13 deletions

View File

@ -515,10 +515,10 @@ public class LocalRecorder implements Recorder {
public void delete(Recording recording) throws IOException { public void delete(Recording recording) throws IOException {
File recordingsDir = new File(config.getSettings().recordingsDir); File recordingsDir = new File(config.getSettings().recordingsDir);
File directory = new File(recordingsDir, recording.getPath()); File directory = new File(recordingsDir, recording.getPath());
delete(directory, new File[] {}); delete(directory);
} }
private void delete(File directory, File... excludes) throws IOException { private void delete(File directory) throws IOException {
if (!directory.exists()) { if (!directory.exists()) {
throw new IOException("Recording does not exist"); throw new IOException("Recording does not exist");
} }
@ -528,18 +528,8 @@ public class LocalRecorder implements Recorder {
File[] files = directory.listFiles(); File[] files = directory.listFiles();
boolean deletedAllFiles = true; boolean deletedAllFiles = true;
for (File file : files) { for (File file : files) {
boolean skip = false;
for (File exclude : excludes) {
if (file.equals(exclude)) {
skip = true;
break;
}
}
if (skip) {
continue;
}
try { try {
LOG.debug("Deleting {}", file.getAbsolutePath());
Files.delete(file.toPath()); Files.delete(file.toPath());
} catch (Exception e) { } catch (Exception e) {
deletedAllFiles = false; deletedAllFiles = false;
@ -548,10 +538,16 @@ public class LocalRecorder implements Recorder {
} }
if (deletedAllFiles) { if (deletedAllFiles) {
LOG.debug("All files deleted");
for (String file : directory.list()) {
LOG.debug(file);
}
if (directory.list().length == 0) { if (directory.list().length == 0) {
LOG.debug("Deleting directory {}", directory);
boolean deleted = directory.delete(); boolean deleted = directory.delete();
if (deleted) { if (deleted) {
if (directory.getParentFile().list().length == 0) { if (directory.getParentFile().list().length == 0) {
LOG.debug("Deleting parent directory {}", directory.getParentFile());
directory.getParentFile().delete(); directory.getParentFile().delete();
} }
} else { } else {