Check the return value of `delete` calls

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
master
jvoisin 5 years ago committed by Andrew DeMaria
parent 4b3890f6ec
commit 6f590f7740
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 4
      airsonic-main/src/main/java/org/airsonic/player/ajax/CoverArtService.java
  2. 3
      airsonic-main/src/main/java/org/airsonic/player/filter/BootstrapVerificationFilter.java
  3. 4
      airsonic-main/src/main/java/org/airsonic/player/service/PodcastService.java

@ -160,7 +160,9 @@ public class CoverArtService {
private void backup(File newCoverFile, File backup) { private void backup(File newCoverFile, File backup) {
if (newCoverFile.exists()) { if (newCoverFile.exists()) {
if (backup.exists()) { if (backup.exists()) {
backup.delete(); if (!backup.delete()) {
LOG.warn("Failed to delete " + backup);
}
} }
if (newCoverFile.renameTo(backup)) { if (newCoverFile.renameTo(backup)) {
LOG.info("Backed up old image file to " + backup); LOG.info("Backed up old image file to " + backup);

@ -90,8 +90,7 @@ public class BootstrapVerificationFilter implements Filter {
private boolean directoryWritable(File dir) { private boolean directoryWritable(File dir) {
try { try {
File tempFile = File.createTempFile("test", null, dir); File tempFile = File.createTempFile("test", null, dir);
tempFile.delete(); return tempFile.delete();
return true;
} catch (IOException x) { } catch (IOException x) {
return false; return false;
} }

@ -579,7 +579,9 @@ public class PodcastService {
if (isEpisodeDeleted(episode)) { if (isEpisodeDeleted(episode)) {
LOG.info("Podcast " + episode.getUrl() + " was deleted. Aborting download."); LOG.info("Podcast " + episode.getUrl() + " was deleted. Aborting download.");
FileUtil.closeQuietly(out); FileUtil.closeQuietly(out);
file.delete(); if (!file.delete()) {
LOG.warn("Unable to delete " + file);
}
} else { } else {
addMediaFileIdToEpisodes(Arrays.asList(episode)); addMediaFileIdToEpisodes(Arrays.asList(episode));
episode.setBytesDownloaded(bytesDownloaded); episode.setBytesDownloaded(bytesDownloaded);

Loading…
Cancel
Save