Vladsz83 commented on code in PR #13577:
URL: https://github.com/apache/ignite/pull/13577#discussion_r4092549858
##########
modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/IgniteSnapshotManager.java:
##########
@@ -701,46 +708,108 @@ public IgniteSnapshotManager(GridKernalContext ctx) {
/**
* @param snpDir Snapshot dir.
*/
- public void deleteSnapshot(File snpDir) {
+ public void deleteLocalSnapshot(File snpDir) {
if (!snpDir.exists())
return;
if (!snpDir.isDirectory())
return;
- deleteSnapshot(new SnapshotFileTree(
+ var sft = new SnapshotFileTree(
cctx.kernalContext(),
snpDir.getName(),
snpDir.getParent(),
ft.folderName(),
- pdsSettings.consistentId().toString()));
+ pdsSettings.consistentId().toString()
+ );
+
+ deleteLocalSnapshot(sft, null);
}
- /** */
- public void deleteSnapshot(SnapshotFileTree sft) {
+ /**
+ * Tries to delete local snapshot data.
+ *
+ * @param sft Snapshot file tree.
+ * @param existsFlag Flag to set {@code true} if any snapshot file or
directory was found (existed). If {@code null}, ignored.
+ * @return {@code True}, if data is found and completely deleted;
+ * {@code False}, if nothing found or if data is found but might
not be deleted completely.
+ */
+ public boolean deleteLocalSnapshot(SnapshotFileTree sft, @Nullable
AtomicBoolean existsFlag) {
+ var exFlag0 = new AtomicBoolean();
+
+ sft.allStorages().forEach(s -> {
+ if (s.exists())
+ exFlag0.set(true);
+ });
+
+ if (sft.root().exists())
+ exFlag0.set(true);
+
+ if (existsFlag != null)
+ existsFlag.set(exFlag0.get());
+
+ // Nothing to delete.
+ if (!exFlag0.get())
+ return false;
+
+ boolean res = true;
+
try {
- U.delete(sft.binaryMeta());
- sft.allStorages().forEach(U::delete);
- U.delete(sft.meta());
+ if (sft.binaryMeta().exists() && !U.delete(sft.binaryMeta()) &&
sft.binaryMeta().exists())
Review Comment:
Simplified but in another manner. Added a comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]