Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class LimitedTemporaryStorage implements Closeable

private volatile boolean closed = false;

private boolean createdStorageDirectory = false;

public LimitedTemporaryStorage(File storageDirectory, long maxBytesUsed)
{
this.storageDirectory = storageDirectory;
Expand Down Expand Up @@ -81,6 +83,9 @@ public LimitedOutputStream createFile() throws IOException
}

FileUtils.forceMkdir(storageDirectory);
if (!createdStorageDirectory) {
createdStorageDirectory = true;
}

final File theFile = new File(storageDirectory, StringUtils.format("%08d.tmp", files.size()));
final EnumSet<StandardOpenOption> openOptions = EnumSet.of(
Expand Down Expand Up @@ -126,7 +131,7 @@ public void close()
delete(file);
}
files.clear();
if (storageDirectory.exists() && !storageDirectory.delete()) {
if (createdStorageDirectory && storageDirectory.exists() && !storageDirectory.delete()) {
log.warn("Cannot delete storageDirectory: %s", storageDirectory);
}
}
Expand Down