Skip to content

Commit

Permalink
Don't stop clean up when a file cannot be removed
Browse files Browse the repository at this point in the history
WE have handled only IOException, but when a file cannot be removed due
to insufficient permissions then SecurityException is raised and because
of that we didn't continue with the removal of other directories.

Bug-Url: https://bugzilla.redhat.com/2151549
Signed-off-by: Martin Perina <mperina@redhat.com>
  • Loading branch information
mwperina committed Feb 8, 2023
1 parent d9e3e93 commit 982b9cd
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.ovirt.engine.core.bll.validator;

import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
Expand Down Expand Up @@ -56,7 +55,7 @@ private void checkExecutionTimeStamp() {
creationInDays = Files.readAttributes(file.toPath(), BasicFileAttributes.class)
.creationTime()
.to(TimeUnit.DAYS);
} catch (IOException e) {
} catch (Exception e) {
log.error("Failed to read file '{}' attributes: {}", file.getAbsolutePath(), e.getMessage());
log.debug("Exception: ", e);
return;
Expand All @@ -75,7 +74,7 @@ private void checkExecutionTimeStamp() {
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
} catch (IOException e) {
} catch (Exception e) {
log.error("Failed to delete dir '{}' content: {}", file.getAbsolutePath(), e.getMessage());
log.debug("Exception: ", e);
}
Expand Down

0 comments on commit 982b9cd

Please sign in to comment.