|
|
|
@ -401,26 +401,12 @@ public class ArbitraryDataFile {
|
|
|
|
|
return fileDeleted || metadataDeleted || chunksDeleted; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected void cleanupFilesystem() { |
|
|
|
|
protected void cleanupFilesystem() throws IOException { |
|
|
|
|
// It is essential that use a separate path reference in this method
|
|
|
|
|
// as we don't want to modify this.filePath
|
|
|
|
|
Path path = this.filePath; |
|
|
|
|
|
|
|
|
|
// Iterate through two levels of parent directories, and delete if empty
|
|
|
|
|
for (int i=0; i<2; i++) { |
|
|
|
|
Path directory = path.getParent().toAbsolutePath(); |
|
|
|
|
try (Stream<Path> files = Files.list(directory)) { |
|
|
|
|
final long count = files.count(); |
|
|
|
|
if (count == 0) { |
|
|
|
|
if (FilesystemUtils.pathInsideDataOrTempPath(directory)) { |
|
|
|
|
Files.delete(directory); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (IOException e) { |
|
|
|
|
LOGGER.warn("Unable to count files in directory", e); |
|
|
|
|
} |
|
|
|
|
path = directory; |
|
|
|
|
} |
|
|
|
|
FilesystemUtils.safeDeleteEmptyParentDirectories(path); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public byte[] getBytes() { |
|
|
|
|