Handle race in EncFSLocalFileProvider.listFiles()
It's possible for the source directory to be deleted after the isDirectory() check but before the File.listFiles() call, so we should handle this case by throwing an exception.
This commit is contained in:
parent
2ec34cfb76
commit
d1d14bea35
1 changed files with 9 additions and 0 deletions
|
@ -112,6 +112,15 @@ public class EncFSLocalFileProvider implements EncFSFileProvider {
|
|||
}
|
||||
|
||||
File[] files = srcDir.listFiles();
|
||||
if (files == null) {
|
||||
/*
|
||||
* It's possible for a race condition to occur and srcDir to be
|
||||
* renamed or deleted between the isDirectory() check above and the
|
||||
* listFiles() call after it. We throw an exception in this case.
|
||||
*/
|
||||
throw new IOException("Path: " + dirPath + " was removed!");
|
||||
}
|
||||
|
||||
List<EncFSFileInfo> results = new ArrayList<EncFSFileInfo>(files.length);
|
||||
for (File file : files) {
|
||||
results.add(convertToFileInfo(file));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue