@@ -68,23 +68,23 @@ const NULL_VERSION_ID = 'null';
68
68
const NULL_VERSION_SUFFIX = '_' + NULL_VERSION_ID ;
69
69
const XATTR_STORAGE_CLASS_KEY = XATTR_USER_PREFIX + 'storage_class' ;
70
70
71
- const versioning_status_enum = {
71
+ const VERSIONING_STATUS_ENUM = Object . freeze ( {
72
72
VER_ENABLED : 'ENABLED' ,
73
73
VER_SUSPENDED : 'SUSPENDED' ,
74
74
VER_DISABLED : 'DISABLED'
75
- } ;
75
+ } ) ;
76
76
const version_format = / ^ [ a - z 0 - 9 ] + $ / ;
77
77
78
78
// describes the status of the copy that was done, default is fallback
79
79
// LINKED = the file was linked on the server side
80
80
// IS_SAME_INODE = source and target are the same inode, nothing to copy
81
81
// FALLBACK = will be reported when link on server side copy failed
82
82
// or on non server side copy
83
- const copy_status_enum = {
83
+ const COPY_STATUS_ENUM = Object . freeze ( {
84
84
LINKED : 'LINKED' ,
85
85
SAME_INODE : 'SAME_INODE' ,
86
86
FALLBACK : 'FALLBACK'
87
- } ;
87
+ } ) ;
88
88
89
89
const XATTR_METADATA_IGNORE_LIST = [
90
90
XATTR_STORAGE_CLASS_KEY ,
@@ -486,7 +486,7 @@ class NamespaceFS {
486
486
this . bucket_id = bucket_id ;
487
487
this . namespace_resource_id = namespace_resource_id ;
488
488
this . access_mode = access_mode ;
489
- this . versioning = ( config . NSFS_VERSIONING_ENABLED && versioning ) || versioning_status_enum . VER_DISABLED ;
489
+ this . versioning = ( config . NSFS_VERSIONING_ENABLED && versioning ) || VERSIONING_STATUS_ENUM . VER_DISABLED ;
490
490
this . stats = stats ;
491
491
this . force_md5_etag = force_md5_etag ;
492
492
this . warmup_buffer = nb_native ( ) . fs . dio_buffer_alloc ( 4096 ) ;
@@ -1209,7 +1209,7 @@ class NamespaceFS {
1209
1209
await this . _throw_if_storage_class_not_supported ( params . storage_class ) ;
1210
1210
1211
1211
upload_params = await this . _start_upload ( fs_context , object_sdk , file_path , params , open_mode ) ;
1212
- if ( ! params . copy_source || upload_params . copy_res === copy_status_enum . FALLBACK ) {
1212
+ if ( ! params . copy_source || upload_params . copy_res === COPY_STATUS_ENUM . FALLBACK ) {
1213
1213
// We are taking the buffer size closest to the sized upload
1214
1214
const bp = multi_buffer_pool . get_buffers_pool ( params . size ) ;
1215
1215
const upload_res = await bp . sem . surround_count (
@@ -1254,16 +1254,16 @@ class NamespaceFS {
1254
1254
1255
1255
let copy_res ;
1256
1256
if ( force_copy_fallback ) {
1257
- copy_res = copy_status_enum . FALLBACK ;
1257
+ copy_res = COPY_STATUS_ENUM . FALLBACK ;
1258
1258
} else if ( params . copy_source ) {
1259
1259
copy_res = await this . _try_copy_file ( fs_context , params , file_path , upload_path ) ;
1260
1260
}
1261
1261
1262
1262
if ( copy_res ) {
1263
- if ( copy_res !== copy_status_enum . FALLBACK ) {
1263
+ if ( copy_res !== COPY_STATUS_ENUM . FALLBACK ) {
1264
1264
// open file after copy link/same inode should use read open mode
1265
1265
open_mode = config . NSFS_OPEN_READ_MODE ;
1266
- if ( copy_res === copy_status_enum . SAME_INODE ) open_path = file_path ;
1266
+ if ( copy_res === COPY_STATUS_ENUM . SAME_INODE ) open_path = file_path ;
1267
1267
}
1268
1268
}
1269
1269
const target_file = await native_fs_utils . open_file ( fs_context , this . bucket_path , open_path , open_mode ) ;
@@ -1280,15 +1280,15 @@ class NamespaceFS {
1280
1280
const source_file_path = await this . _find_version_path ( fs_context , params . copy_source ) ;
1281
1281
await this . _check_path_in_bucket_boundaries ( fs_context , source_file_path ) ;
1282
1282
// await this._fail_if_archived_or_sparse_file(fs_context, source_file_path, stat);
1283
- let res = copy_status_enum . FALLBACK ;
1283
+ let res = COPY_STATUS_ENUM . FALLBACK ;
1284
1284
if ( this . _is_versioning_disabled ( ) ) {
1285
1285
try {
1286
1286
// indicates a retry situation in which the source and target point to the same inode
1287
1287
const same_inode = await this . _is_same_inode ( fs_context , source_file_path , file_path ) ;
1288
- if ( same_inode ) return copy_status_enum . SAME_INODE ;
1288
+ if ( same_inode ) return COPY_STATUS_ENUM . SAME_INODE ;
1289
1289
// Doing a hard link.
1290
1290
await nb_native ( ) . fs . link ( fs_context , source_file_path , upload_path ) ;
1291
- res = copy_status_enum . LINKED ;
1291
+ res = COPY_STATUS_ENUM . LINKED ;
1292
1292
} catch ( e ) {
1293
1293
dbg . warn ( 'NamespaceFS: COPY using link failed with:' , e ) ;
1294
1294
}
@@ -1337,8 +1337,8 @@ class NamespaceFS {
1337
1337
async _finish_upload ( { fs_context, params, open_mode, target_file, upload_path, file_path, digest = undefined ,
1338
1338
copy_res = undefined , offset } ) {
1339
1339
const part_upload = file_path === upload_path ;
1340
- const same_inode = params . copy_source && copy_res === copy_status_enum . SAME_INODE ;
1341
- const should_replace_xattr = params . copy_source ? copy_res === copy_status_enum . FALLBACK : true ;
1340
+ const same_inode = params . copy_source && copy_res === COPY_STATUS_ENUM . SAME_INODE ;
1341
+ const should_replace_xattr = params . copy_source ? copy_res === COPY_STATUS_ENUM . FALLBACK : true ;
1342
1342
const is_dir_content = this . _is_directory_content ( file_path , params . key ) ;
1343
1343
1344
1344
const stat = await target_file . stat ( fs_context ) ;
@@ -2693,15 +2693,15 @@ class NamespaceFS {
2693
2693
//////////////////////////
2694
2694
2695
2695
_is_versioning_enabled ( ) {
2696
- return this . versioning === versioning_status_enum . VER_ENABLED ;
2696
+ return this . versioning === VERSIONING_STATUS_ENUM . VER_ENABLED ;
2697
2697
}
2698
2698
2699
2699
_is_versioning_disabled ( ) {
2700
- return this . versioning === versioning_status_enum . VER_DISABLED ;
2700
+ return this . versioning === VERSIONING_STATUS_ENUM . VER_DISABLED ;
2701
2701
}
2702
2702
2703
2703
_is_versioning_suspended ( ) {
2704
- return this . versioning === versioning_status_enum . VER_SUSPENDED ;
2704
+ return this . versioning === VERSIONING_STATUS_ENUM . VER_SUSPENDED ;
2705
2705
}
2706
2706
2707
2707
_get_version_id_by_mode ( stat ) {
@@ -2786,7 +2786,7 @@ class NamespaceFS {
2786
2786
}
2787
2787
2788
2788
_throw_if_delete_marker ( stat , params ) {
2789
- if ( this . versioning === versioning_status_enum . VER_ENABLED || this . versioning === versioning_status_enum . VER_SUSPENDED ) {
2789
+ if ( this . versioning === VERSIONING_STATUS_ENUM . VER_ENABLED || this . versioning === VERSIONING_STATUS_ENUM . VER_SUSPENDED ) {
2790
2790
const xattr_delete_marker = stat . xattr [ XATTR_DELETE_MARKER ] ;
2791
2791
if ( xattr_delete_marker ) {
2792
2792
const basic_err = error_utils . new_error_code ( 'ENOENT' , 'Entry is a delete marker' ) ;
0 commit comments