Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix regression in Util#listFiles() in config restoration.
I was able to test it after the [JENKINS-44997](https://issues.jenkins-ci.org/browse/JENKINS-44997) fix

File#listFiles() returns empty list when the file does not exist.
But in my case I was getting Error due to the isDirectory() check

#10
  • Loading branch information
oleg-nenashev committed Jun 21, 2017
1 parent 17c9607 commit 22ae79a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main/java/org/jenkinsci/plugins/periodicbackup/Util.java
Expand Up @@ -167,14 +167,20 @@ public static File[] listFiles(@Nonnull File directory) throws PeriodicBackupExc

/**
* Secure version of the listFiles() logic
* @param directory Directory to be listed
* @param directory Directory to be listed
* @param fileFilter Optional file filter
* @return Files in the directory
* @return Files in the directory.
* If the directory does not exist, an empty list will be returned
* @throws PeriodicBackupException Whatever error
*/
@Nonnull
@Restricted(NoExternalUse.class)
public static File[] listFiles(@Nonnull File directory, @CheckForNull FileFilter fileFilter) throws PeriodicBackupException {
if (!directory.exists()) {
// Not our business to check if the directory exists
return new File[0];
}

if (!directory.isDirectory()) {
throw new PeriodicBackupException(formatMessage(directory, "File is not a directory"));
}
Expand Down

0 comments on commit 22ae79a

Please sign in to comment.