Skip to content

Commit

Permalink
If atomic move fails, perform a normal move (#4221)
Browse files Browse the repository at this point in the history
* Move previously experimental endpoints to their correct locations

Also deprecated old endpoints in favour of the new endpoints, as the old ones will cease to function when altair comes online.

fixes #3703

Signed-off-by: Paul Harris <[email protected]>
  • Loading branch information
rolfyone authored Aug 6, 2021
1 parent e137ce3 commit c18fe87
Showing 1 changed file with 2 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.function.Consumer;
import org.apache.commons.io.FileUtils;
Expand Down Expand Up @@ -109,20 +108,14 @@ void openDatabases(
@VisibleForTesting
void swapActiveDatabase() throws DatabaseMigraterError {
try {
Files.move(
dataDirLayout.getBeaconDataDirectory(),
getMovedOldBeaconFolderPath(),
StandardCopyOption.ATOMIC_MOVE);
Files.move(dataDirLayout.getBeaconDataDirectory(), getMovedOldBeaconFolderPath());
} catch (IOException ex) {
statusUpdater.accept(ex.getMessage());
throw new DatabaseMigraterError(
"Failed to move old database to " + getMovedOldBeaconFolderPath().toString());
}
try {
Files.move(
getNewBeaconFolderPath(),
dataDirLayout.getBeaconDataDirectory(),
StandardCopyOption.ATOMIC_MOVE);
Files.move(getNewBeaconFolderPath(), dataDirLayout.getBeaconDataDirectory());
} catch (IOException ex) {
statusUpdater.accept(ex.getMessage());
throw new DatabaseMigraterError(
Expand Down

0 comments on commit c18fe87

Please sign in to comment.