Skip to content

Commit

Permalink
FIX for dele folder #7
Browse files Browse the repository at this point in the history
  • Loading branch information
mspasiano committed Feb 27, 2020
1 parent 24c1cd6 commit fd3c957
Showing 1 changed file with 15 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,20 +155,24 @@ public InputStream getInputStream(String key, Boolean majorVersion) {
@Override
public Boolean delete(String id) {
try {

Path objectPath = absolutizePath(Paths.get(id));
Path parent = objectPath.getParent();
Files.walk(parent).filter(path -> path.getFileName().toString().startsWith(objectPath.getFileName().toString()))
if (Files.isDirectory(objectPath)) {
Files.walk(objectPath)
.sorted(Comparator.reverseOrder())
.map(Path::toFile).forEach(File::delete);

// Files.walk(objectPath)
// .sorted(Comparator.reverseOrder())
// .map(Path::toFile)
// .forEach(File::delete);

.map(Path::toFile)
.forEach(File::delete);

} else {
Path parent = objectPath.getParent();
Files.walk(parent)
.filter(path -> {
return path.getFileName().toString().startsWith(objectPath.getFileName().toString());
})
.sorted(Comparator.reverseOrder())
.map(Path::toFile)
.forEach(File::delete);
}
return !Files.exists(objectPath);

} catch (IOException e) {
throw new StorageException(StorageException.Type.GENERIC, "Unable to delete "+ id, e);
}
Expand Down

0 comments on commit fd3c957

Please sign in to comment.