@@ -736,12 +736,12 @@ class NamespaceFS {
736
736
/**
737
737
* @param {fs.Dirent } ent
738
738
*/
739
- const process_entry = async ent => {
739
+ const process_entry = async ( ent , is_disabled_dir_content ) => {
740
740
// dbg.log0('process_entry', dir_key, ent.name);
741
- if ( ( ! ent . name . startsWith ( prefix_ent ) ||
741
+ if ( ! ent . name . startsWith ( prefix_ent ) ||
742
742
ent . name < marker_curr ||
743
743
ent . name === this . get_bucket_tmpdir_name ( ) ||
744
- ent . name === config . NSFS_FOLDER_OBJECT_NAME ) ||
744
+ ( ent . name === config . NSFS_FOLDER_OBJECT_NAME && is_disabled_dir_content ) ||
745
745
this . _is_hidden_version_path ( ent . name ) ) {
746
746
return ;
747
747
}
@@ -756,7 +756,7 @@ class NamespaceFS {
756
756
} ;
757
757
} else {
758
758
r = {
759
- key : this . _get_entry_key ( dir_key , ent , isDir ) ,
759
+ key : this . _get_entry_key ( dir_key , ent , isDir , is_disabled_dir_content ) ,
760
760
common_prefix : isDir ,
761
761
is_latest : true
762
762
} ;
@@ -781,8 +781,8 @@ class NamespaceFS {
781
781
782
782
// insert dir object to objects list if its key is lexicographicly bigger than the key marker &&
783
783
// no delimiter OR prefix is the current directory entry
784
- const is_dir_content = cached_dir . stat . xattr && cached_dir . stat . xattr [ XATTR_DIR_CONTENT ] ;
785
- if ( is_dir_content && dir_key > key_marker && ( ! delimiter || dir_key === prefix ) ) {
784
+ const is_disabled_dir_content = cached_dir . stat . xattr && cached_dir . stat . xattr [ XATTR_DIR_CONTENT ] ;
785
+ if ( is_disabled_dir_content && dir_key > key_marker && ( ! delimiter || dir_key === prefix ) ) {
786
786
const r = { key : dir_key , common_prefix : false } ;
787
787
await insert_entry_to_results_arr ( r ) ;
788
788
}
@@ -835,7 +835,7 @@ class NamespaceFS {
835
835
if ( ent . name === config . NSFS_FOLDER_OBJECT_NAME && dir_key === marker_dir ) {
836
836
continue ;
837
837
}
838
- await process_entry ( ent ) ;
838
+ await process_entry ( ent , is_disabled_dir_content ) ;
839
839
// since we traverse entries in sorted order,
840
840
// we can break as soon as enough keys are collected.
841
841
if ( is_truncated ) break ;
@@ -883,6 +883,17 @@ class NamespaceFS {
883
883
}
884
884
} ;
885
885
886
+ const format_key_name = obj_info => {
887
+ if ( this . _is_hidden_version_path ( obj_info . key ) ) {
888
+ obj_info . key = path . normalize ( obj_info . key . replace ( HIDDEN_VERSIONS_PATH + '/' , '' ) ) ;
889
+ obj_info . key = _get_filename ( obj_info . key ) ;
890
+ set_latest_delete_marker ( obj_info ) ;
891
+ }
892
+ if ( obj_info . key . endsWith ( config . NSFS_FOLDER_OBJECT_NAME ) ) {
893
+ obj_info . key = obj_info . key . slice ( 0 , - config . NSFS_FOLDER_OBJECT_NAME . length ) ;
894
+ }
895
+ } ;
896
+
886
897
const prefix_dir_key = prefix . slice ( 0 , prefix . lastIndexOf ( '/' ) + 1 ) ;
887
898
await process_dir ( prefix_dir_key ) ;
888
899
await Promise . all ( results . map ( async r => {
@@ -908,11 +919,7 @@ class NamespaceFS {
908
919
if ( ! list_versions && obj_info . delete_marker ) {
909
920
continue ;
910
921
}
911
- if ( this . _is_hidden_version_path ( obj_info . key ) ) {
912
- obj_info . key = path . normalize ( obj_info . key . replace ( HIDDEN_VERSIONS_PATH + '/' , '' ) ) ;
913
- obj_info . key = _get_filename ( obj_info . key ) ;
914
- set_latest_delete_marker ( obj_info ) ;
915
- }
922
+ format_key_name ( obj_info ) ;
916
923
res . objects . push ( obj_info ) ;
917
924
previous_key = obj_info . key ;
918
925
}
@@ -1215,7 +1222,7 @@ class NamespaceFS {
1215
1222
try {
1216
1223
await this . _check_path_in_bucket_boundaries ( fs_context , file_path ) ;
1217
1224
1218
- if ( this . should_use_empty_content_dir_optimization ( ) && this . empty_dir_content_flow ( file_path , params ) ) {
1225
+ if ( this . _is_versioning_disabled ( ) && this . empty_dir_content_flow ( file_path , params ) ) {
1219
1226
const content_dir_info = await this . _create_empty_dir_content ( fs_context , params , file_path ) ;
1220
1227
return content_dir_info ;
1221
1228
}
@@ -1353,8 +1360,7 @@ class NamespaceFS {
1353
1360
const part_upload = file_path === upload_path ;
1354
1361
const same_inode = params . copy_source && copy_res === COPY_STATUS_ENUM . SAME_INODE ;
1355
1362
const should_replace_xattr = params . copy_source ? copy_res === COPY_STATUS_ENUM . FALLBACK : true ;
1356
- const is_dir_content_optimized_flow = this . _is_directory_content ( file_path , params . key ) &&
1357
- this . should_use_empty_content_dir_optimization ( ) ;
1363
+ const is_disabled_dir_content = this . _is_directory_content ( file_path , params . key ) && this . _is_versioning_disabled ( ) ;
1358
1364
1359
1365
const stat = await target_file . stat ( fs_context ) ;
1360
1366
this . _verify_encryption ( params . encryption , this . _get_encryption_info ( stat ) ) ;
@@ -1397,21 +1403,20 @@ class NamespaceFS {
1397
1403
} ) ;
1398
1404
}
1399
1405
}
1400
- if ( fs_xattr && ! is_dir_content_optimized_flow && should_replace_xattr ) {
1406
+ if ( fs_xattr && ! is_disabled_dir_content && should_replace_xattr ) {
1401
1407
await target_file . replacexattr ( fs_context , fs_xattr ) ;
1402
1408
}
1403
1409
// fsync
1404
1410
if ( config . NSFS_TRIGGER_FSYNC ) await target_file . fsync ( fs_context ) ;
1405
1411
dbg . log1 ( 'NamespaceFS._finish_upload:' , open_mode , file_path , upload_path , fs_xattr ) ;
1406
1412
1407
1413
if ( ! same_inode && ! part_upload ) {
1408
- await this . _move_to_dest ( fs_context , upload_path , file_path , target_file , open_mode , params . key ,
1409
- is_dir_content_optimized_flow ) ;
1414
+ await this . _move_to_dest ( fs_context , upload_path , file_path , target_file , open_mode , params . key ) ;
1410
1415
}
1411
1416
1412
1417
// when object is a dir, xattr are set on the folder itself and the content is in .folder file
1413
1418
// we still should put the xattr if copy is link/same inode because we put the xattr on the directory
1414
- if ( is_dir_content_optimized_flow ) {
1419
+ if ( is_disabled_dir_content ) {
1415
1420
await this . _assign_dir_content_to_xattr ( fs_context , fs_xattr , { ...params , size : stat . size } , copy_xattr ) ;
1416
1421
}
1417
1422
stat . xattr = { ...stat . xattr , ...fs_xattr } ;
@@ -1439,14 +1444,14 @@ class NamespaceFS {
1439
1444
}
1440
1445
1441
1446
// move to dest GPFS (wt) / POSIX (w / undefined) - non part upload
1442
- async _move_to_dest ( fs_context , source_path , dest_path , target_file , open_mode , key , is_dir_content_optimized_flow ) {
1443
- dbg . log2 ( '_move_to_dest' , fs_context , source_path , dest_path , target_file , open_mode , key , is_dir_content_optimized_flow ) ;
1447
+ async _move_to_dest ( fs_context , source_path , dest_path , target_file , open_mode , key ) {
1448
+ dbg . log2 ( '_move_to_dest' , fs_context , source_path , dest_path , target_file , open_mode , key ) ;
1444
1449
let retries = config . NSFS_RENAME_RETRIES ;
1445
1450
// will retry renaming a file in case of parallel deleting of the destination path
1446
1451
for ( ; ; ) {
1447
1452
try {
1448
1453
await native_fs_utils . _make_path_dirs ( dest_path , fs_context ) ;
1449
- if ( this . _is_versioning_disabled ( ) || is_dir_content_optimized_flow ) {
1454
+ if ( this . _is_versioning_disabled ( ) ) {
1450
1455
if ( open_mode === 'wt' ) {
1451
1456
await target_file . linkfileat ( fs_context , dest_path ) ;
1452
1457
} else {
@@ -1989,7 +1994,7 @@ class NamespaceFS {
1989
1994
if ( is_key_dir_path && ! params . key . endsWith ( '/' ) ) {
1990
1995
return { } ;
1991
1996
}
1992
- if ( this . _is_versioning_disabled ( ) || ( is_key_dir_path && this . should_use_empty_content_dir_optimization ( ) ) ) {
1997
+ if ( this . _is_versioning_disabled ( ) ) {
1993
1998
// TODO- Directory object (key/) is currently can't co-exist while key (without slash) exists. see -https://github.com/noobaa/noobaa-core/issues/8320
1994
1999
await this . _delete_single_object ( fs_context , file_path , params ) ;
1995
2000
} else {
@@ -2111,13 +2116,8 @@ class NamespaceFS {
2111
2116
2112
2117
async delete_object_tagging ( params , object_sdk ) {
2113
2118
dbg . log0 ( 'NamespaceFS.delete_object_tagging:' , params ) ;
2114
- let file_path ;
2115
- if ( params . version_id && this . _is_versioning_enabled ( ) ) {
2116
- file_path = this . _get_version_path ( params . key , params . version_id ) ;
2117
- } else {
2118
- file_path = this . _get_file_path ( params ) ;
2119
- }
2120
2119
const fs_context = this . prepare_fs_context ( object_sdk ) ;
2120
+ const file_path = await this . _find_version_path ( fs_context , params , true ) ;
2121
2121
try {
2122
2122
await this . _clear_user_xattr ( fs_context , file_path , XATTR_TAG ) ;
2123
2123
} catch ( err ) {
@@ -2133,13 +2133,8 @@ class NamespaceFS {
2133
2133
for ( const [ xattr_key , xattr_value ] of Object . entries ( tagging ) ) {
2134
2134
fs_xattr [ XATTR_TAG + xattr_key ] = xattr_value ;
2135
2135
}
2136
- let file_path ;
2137
- if ( params . version_id && this . _is_versioning_enabled ( ) ) {
2138
- file_path = this . _get_version_path ( params . key , params . version_id ) ;
2139
- } else {
2140
- file_path = this . _get_file_path ( params ) ;
2141
- }
2142
2136
const fs_context = this . prepare_fs_context ( object_sdk ) ;
2137
+ const file_path = await this . _find_version_path ( fs_context , params , true ) ;
2143
2138
dbg . log0 ( 'NamespaceFS.put_object_tagging: fs_xattr ' , fs_xattr , 'file_path :' , file_path ) ;
2144
2139
try {
2145
2140
// remove existng tag before putting new tags
@@ -2439,8 +2434,8 @@ class NamespaceFS {
2439
2434
* @param {fs.Dirent } ent
2440
2435
* @returns {string }
2441
2436
*/
2442
- _get_entry_key ( dir_key , ent , isDir ) {
2443
- if ( ent . name === config . NSFS_FOLDER_OBJECT_NAME ) return dir_key ;
2437
+ _get_entry_key ( dir_key , ent , isDir , is_disabled_dir_content ) {
2438
+ if ( ent . name === config . NSFS_FOLDER_OBJECT_NAME && is_disabled_dir_content ) return dir_key ;
2444
2439
return dir_key + ent . name + ( isDir ? '/' : '' ) ;
2445
2440
}
2446
2441
@@ -2450,7 +2445,6 @@ class NamespaceFS {
2450
2445
* @returns {string }
2451
2446
*/
2452
2447
_get_version_entry_key ( dir_key , ent ) {
2453
- if ( ent . name === config . NSFS_FOLDER_OBJECT_NAME ) return dir_key ;
2454
2448
return dir_key + HIDDEN_VERSIONS_PATH + '/' + ent . name ;
2455
2449
}
2456
2450
@@ -2765,9 +2759,6 @@ class NamespaceFS {
2765
2759
return is_dir_content && params . size === 0 ;
2766
2760
}
2767
2761
2768
- should_use_empty_content_dir_optimization ( ) {
2769
- return this . _is_versioning_disabled ( ) || ! config . NSFS_CONTENT_DIRECTORY_VERSIONING_ENABLED ;
2770
- }
2771
2762
/**
2772
2763
* returns if should force md5 calculation for the bucket/account.
2773
2764
* first check if defined for bucket / account, if not use global default
0 commit comments