Fix .no_recover files never being cleaned up (fixes #497)
This commit is contained in:
@@ -325,6 +325,18 @@ public class ReplayMod implements Module, Scheduler {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup leftover no_recover files
|
||||||
|
try (DirectoryStream<Path> paths = Files.newDirectoryStream(getReplayFolder())) {
|
||||||
|
for (Path path : paths) {
|
||||||
|
String name = path.getFileName().toString();
|
||||||
|
if (name.endsWith(".no_recover")) {
|
||||||
|
Files.delete(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,8 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
|
|
||||||
// If we crash right here, on the next start we'll prompt the user for recovery
|
// 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.
|
// 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"));
|
Path noRecoverMarker = outputPath.resolveSibling(outputPath.getFileName() + ".no_recover");
|
||||||
|
Files.createFile(noRecoverMarker);
|
||||||
|
|
||||||
// We still have the replay, so we just save it (at least for a few weeks) in case they change their mind
|
// 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());
|
String replayName = FilenameUtils.getBaseName(outputPath.getFileName().toString());
|
||||||
@@ -287,6 +288,9 @@ public class PacketListener extends ChannelInboundHandlerAdapter {
|
|||||||
Files.createDirectories(rawPath.getParent());
|
Files.createDirectories(rawPath.getParent());
|
||||||
replayFile.saveTo(rawPath.toFile());
|
replayFile.saveTo(rawPath.toFile());
|
||||||
replayFile.close();
|
replayFile.close();
|
||||||
|
|
||||||
|
// Done, clean up the marker
|
||||||
|
Files.delete(noRecoverMarker);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user