@@ -2575,10 +2575,19 @@ class NamespaceFS {
2575
2575
}
2576
2576
}
2577
2577
2578
+ /**
2579
+ * _delete_path_dirs deletes all the paths in the hierarchy that are empty after a successful delete
2580
+ * if dir is not empty it will stop at the first non empty dir
2581
+ * if dir is also a directory object (disabled mode optimization - CONTENT_DIR xattr is on the directory) we stop the loop
2582
+ * @param {String } file_path
2583
+ * @param {nb.NativeFSContext } fs_context
2584
+ */
2578
2585
async _delete_path_dirs ( file_path , fs_context ) {
2579
2586
try {
2580
2587
let dir = path . dirname ( file_path ) ;
2581
2588
while ( dir !== this . bucket_path ) {
2589
+ const dir_stat = await nb_native ( ) . fs . stat ( fs_context , dir ) ;
2590
+ if ( dir_stat . xattr && dir_stat . xattr [ XATTR_DIR_CONTENT ] ) break ;
2582
2591
await nb_native ( ) . fs . rmdir ( fs_context , dir ) ;
2583
2592
dir = path . dirname ( dir ) ;
2584
2593
}
@@ -3016,10 +3025,18 @@ class NamespaceFS {
3016
3025
return res ;
3017
3026
}
3018
3027
3019
- // delete version_id -
3020
- // 1. get version info, if it's empty - return
3021
- // 2. unlink key
3022
- // 3. if version is latest version - promote second latest -> latest
3028
+ /**
3029
+ * delete version_id does the following -
3030
+ * 1. get version info, if it's empty - return
3031
+ * 2. unlink key
3032
+ * 3. if version is latest version - promote second latest -> latest
3033
+ * 4. if it's the latest version - delete the directory hirerachy of the key if it's empty
3034
+ * if it's a past version - delete .versions/ and the directory hirerachy if it's empty
3035
+ * @param {nb.NativeFSContext } fs_context
3036
+ * @param {String } file_path
3037
+ * @param {Object } params
3038
+ * @returns {Promise<{deleted_delete_marker?: string, version_id?: string}> }
3039
+ */
3023
3040
async _delete_version_id ( fs_context , file_path , params ) {
3024
3041
// TODO optimization - GPFS link overrides, no need to unlink before promoting, but if there is nothing to promote we should unlink
3025
3042
const del_obj_version_info = await this . _delete_single_object_versioned ( fs_context , params . key , params . version_id ) ;
0 commit comments