optionally delete empty parent directories

This commit is contained in:
chrislu committed 2025-11-05 21:29:06 -08:00
1 parent 9612457a32
commit a8a4bc06e8
8 files changed
+297 -268

No files matched your search

+13
View File
@@ -295,7 +295,20 @@ func (fs *FilerServer) DeleteEntry(ctx context.Context, req *filer_pb.DeleteEntr
resp = &filer_pb.DeleteEntryResponse{}
if err != nil && err != filer_pb.ErrNotFound {
resp.Error = err.Error()
return resp, nil
}
// Optional cleanup of empty parent directories
if req.DeleteEmptyParentDirectories {
stopAtPath := util.FullPath(req.DeleteEmptyParentDirectoriesStopPath)
if stopAtPath == "" {
stopAtPath = util.FullPath(fs.filer.DirBucketsPath)
}
// Clean up empty parent directories starting from req.Directory
fs.filer.DeleteEmptyParentDirectories(ctx, util.FullPath(req.Directory), stopAtPath)
}
return resp, nil
}