You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by "shwstppr (via GitHub)" <gi...@apache.org> on 2023/05/12 12:33:52 UTC

[GitHub] [cloudstack] shwstppr commented on a diff in pull request #7524: secondary-storage: delete backedup snapshot dir on delete

shwstppr commented on code in PR #7524:
URL: https://github.com/apache/cloudstack/pull/7524#discussion_r1192305234


##########
services/secondary-storage/server/src/main/java/org/apache/cloudstack/storage/resource/NfsSecondaryStorageResource.java:
##########
@@ -1997,6 +1997,17 @@ private void savePostUploadPSK(String psk) {
         }
     }
 
+    protected String getSnapshotFilepathForDelete(String path, String snapshotName) {
+        String finalPath = path + "/*" + snapshotName + "*";
+        if (!path.endsWith(snapshotName)) {
+            return finalPath;
+        }
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug(String.format("Snapshot file %s is present in the same name directory %s. Deleting the directory", snapshotName, path));
+        }
+        return path;
+    }

Review Comment:
   @weizhouapache directory check be added but we always expect it to be a directory anyway as we append the `/*SNAPSHOT_NAME*
   
   And there will always be files (I checked  VMware, Xen and KVM. Snapshots are placed inside the same name folder **only for VMWare**). Example
   
   ```
   [root@sl-nestednfs snapshots]# tree 2/10/
   2/10/
   └── fd57cb44-0559-490c-998d-5313eec52cef
       ├── fd57cb44-0559-490c-998d-5313eec52cef-disk0.vmdk
       ├── fd57cb44-0559-490c-998d-5313eec52cef-disk1.nvram
       └── fd57cb44-0559-490c-998d-5313eec52cef.ovf
   ```



-- 
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: commits-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org