Check the return value of delete calls

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
This commit is contained in:
jvoisin
2019-10-08 00:39:16 -06:00
committed by Andrew DeMaria
parent 4b3890f6ec
commit 6f590f7740
3 changed files with 7 additions and 4 deletions
@@ -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);
@@ -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;
}
@@ -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);