Do not bother recovering useless replays (fixes #444)

Useless replays being those for which auto-recording was disabled and Start
never pressed.
This commit is contained in:
Jonas Herzig
2021-02-16 22:38:39 +01:00
parent dabb64340e
commit 19ff1ef38b
2 changed files with 12 additions and 0 deletions

View File

@@ -476,6 +476,14 @@ public class ReplayMod implements
String name = path.getFileName().toString();
if (name.endsWith(".mcpr.tmp") && Files.isDirectory(path)) {
Path original = path.resolveSibling(FilenameUtils.getBaseName(name));
Path noRecoverMarker = original.resolveSibling(original.getFileName() + ".no_recover");
if (Files.exists(noRecoverMarker)) {
// This file, when its markers are processed, doesn't actually result in any replays.
// So we don't really need to recover it either, let's just get rid of it.
FileUtils.deleteDirectory(path.toFile());
Files.delete(noRecoverMarker);
continue;
}
new RestoreReplayGui(this, GuiScreen.wrap(mc.currentScreen), original.toFile()).display();
}
}

View File

@@ -272,6 +272,10 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
// Immediately close the saving popup, the user doesn't care about it
core.runLater(guiSavingReplay::close);
// If we crash right here, on the next start we'll prompt the user for recovery
// but we don't really want that, so drop a marker file to skip recovery for this replay.
Files.createFile(outputPath.resolveSibling(outputPath.getFileName() + ".no_recover"));
// We still have the replay, so we just save it (at least for a few weeks) in case they change their mind
String replayName = FilenameUtils.getBaseName(outputPath.getFileName().toString());
Path rawFolder = ReplayMod.instance.getRawReplayFolder();