From 6f590f774037766caa5463cfae003c60da2a92dc Mon Sep 17 00:00:00 2001 From: jvoisin Date: Mon, 7 Oct 2019 18:26:04 +0200 Subject: [PATCH] Check the return value of `delete` calls Signed-off-by: Andrew DeMaria --- .../main/java/org/airsonic/player/ajax/CoverArtService.java | 4 +++- .../airsonic/player/filter/BootstrapVerificationFilter.java | 3 +-- .../main/java/org/airsonic/player/service/PodcastService.java | 4 +++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java b/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java index d9c13a10..9d8d3407 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java @@ -160,7 +160,9 @@ public class CoverArtService { private void backup(File newCoverFile, File backup) { if (newCoverFile.exists()) { if (backup.exists()) { - backup.delete(); + if (!backup.delete()) { + LOG.warn("Failed to delete " + backup); + } } if (newCoverFile.renameTo(backup)) { LOG.info("Backed up old image file to " + backup); diff --git a/airsonic-main/src/main/java/org/airsonic/player/filter/BootstrapVerificationFilter.java b/airsonic-main/src/main/java/org/airsonic/player/filter/BootstrapVerificationFilter.java index 7335a3c7..403ff0b0 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/filter/BootstrapVerificationFilter.java +++ b/airsonic-main/src/main/java/org/airsonic/player/filter/BootstrapVerificationFilter.java @@ -90,8 +90,7 @@ public class BootstrapVerificationFilter implements Filter { private boolean directoryWritable(File dir) { try { File tempFile = File.createTempFile("test", null, dir); - tempFile.delete(); - return true; + return tempFile.delete(); } catch (IOException x) { return false; } diff --git a/airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java b/airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java index 5f509c36..c03c528b 100644 --- a/airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java +++ b/airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java @@ -579,7 +579,9 @@ public class PodcastService { if (isEpisodeDeleted(episode)) { LOG.info("Podcast " + episode.getUrl() + " was deleted. Aborting download."); FileUtil.closeQuietly(out); - file.delete(); + if (!file.delete()) { + LOG.warn("Unable to delete " + file); + } } else { addMediaFileIdToEpisodes(Arrays.asList(episode)); episode.setBytesDownloaded(bytesDownloaded);