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
15 changes: 12 additions & 3 deletions src/java/org/apache/cassandra/io/util/PathUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public final class PathUtils

private static volatile boolean DAEMON_SETUP_COMPLETED = false;

private static final CopyOption[] ATOMIC_MOVE_OPTIONS = {
StandardCopyOption.REPLACE_EXISTING,
StandardCopyOption.ATOMIC_MOVE
};

private static final CopyOption[] REPLACE_EXISTING_OPTIONS = {
StandardCopyOption.REPLACE_EXISTING
};

private static Consumer<Path> onDeletion = path -> {
if (DAEMON_SETUP_COMPLETED)
setDeletionListener(ignore -> {});
Expand Down Expand Up @@ -394,7 +403,7 @@ private static void deleteRecursive(Path path, RateLimiter rateLimiter, Consumer

/**
* Recursively delete the content of the directory, but not the directory itself.
* @param dirPath directory for which content should be deleted
* @param dirPath directory for which content should be deleted
*/
public static void deleteContent(Path dirPath)
{
Expand Down Expand Up @@ -496,12 +505,12 @@ private static void atomicMoveWithFallback(Path from, Path to) throws IOExceptio
{
try
{
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING, StandardCopyOption.ATOMIC_MOVE);
Files.move(from, to, ATOMIC_MOVE_OPTIONS);
}
catch (AtomicMoveNotSupportedException e)
{
logger.trace("Could not do an atomic move", e);
Files.move(from, to, StandardCopyOption.REPLACE_EXISTING);
Files.move(from, to, REPLACE_EXISTING_OPTIONS);
}
}

Expand Down