@@ -52,7 +52,6 @@ const multi_buffer_pool = new buffer_utils.MultiSizeBuffersPool({
52
52
53
53
const XATTR_USER_PREFIX = 'user.' ;
54
54
const XATTR_NOOBAA_INTERNAL_PREFIX = XATTR_USER_PREFIX + 'noobaa.' ;
55
- const XATTR_NOOBAA_CUSTOM_PREFIX = XATTR_NOOBAA_INTERNAL_PREFIX + 'tag.' ;
56
55
// TODO: In order to verify validity add content_md5_mtime as well
57
56
const XATTR_MD5_KEY = XATTR_USER_PREFIX + 'content_md5' ;
58
57
const XATTR_CONTENT_TYPE = XATTR_NOOBAA_INTERNAL_PREFIX + 'content_type' ;
@@ -63,6 +62,7 @@ const XATTR_VERSION_ID = XATTR_NOOBAA_INTERNAL_PREFIX + 'version_id';
63
62
const XATTR_PREV_VERSION_ID = XATTR_NOOBAA_INTERNAL_PREFIX + 'prev_version_id' ;
64
63
const XATTR_DELETE_MARKER = XATTR_NOOBAA_INTERNAL_PREFIX + 'delete_marker' ;
65
64
const XATTR_DIR_CONTENT = XATTR_NOOBAA_INTERNAL_PREFIX + 'dir_content' ;
65
+ const XATTR_TAG = XATTR_NOOBAA_INTERNAL_PREFIX + 'tag.' ;
66
66
const HIDDEN_VERSIONS_PATH = '.versions' ;
67
67
const NULL_VERSION_ID = 'null' ;
68
68
const NULL_VERSION_SUFFIX = '_' + NULL_VERSION_ID ;
@@ -1967,9 +1967,9 @@ class NamespaceFS {
1967
1967
const stat = await file . stat ( fs_context ) ;
1968
1968
if ( stat . xattr ) {
1969
1969
for ( const [ xattr_key , xattr_value ] of Object . entries ( stat . xattr ) ) {
1970
- if ( xattr_key . includes ( XATTR_NOOBAA_CUSTOM_PREFIX ) ) {
1970
+ if ( xattr_key . includes ( XATTR_TAG ) ) {
1971
1971
tag_set . push ( {
1972
- key : xattr_key . replace ( XATTR_NOOBAA_CUSTOM_PREFIX , '' ) ,
1972
+ key : xattr_key . replace ( XATTR_TAG , '' ) ,
1973
1973
value : xattr_value ,
1974
1974
} ) ;
1975
1975
}
@@ -1993,7 +1993,7 @@ class NamespaceFS {
1993
1993
}
1994
1994
const fs_context = this . prepare_fs_context ( object_sdk ) ;
1995
1995
try {
1996
- await this . _clear_user_xattr ( fs_context , file_path , XATTR_NOOBAA_CUSTOM_PREFIX ) ;
1996
+ await this . _clear_user_xattr ( fs_context , file_path , XATTR_TAG ) ;
1997
1997
} catch ( err ) {
1998
1998
dbg . error ( `NamespaceFS.delete_object_tagging: failed in dir ${ file_path } with error: ` , err ) ;
1999
1999
throw native_fs_utils . translate_error_codes ( err , native_fs_utils . entity_enum . OBJECT ) ;
@@ -2005,7 +2005,7 @@ class NamespaceFS {
2005
2005
const fs_xattr = { } ;
2006
2006
const tagging = params . tagging && Object . fromEntries ( params . tagging . map ( tag => ( [ tag . key , tag . value ] ) ) ) ;
2007
2007
for ( const [ xattr_key , xattr_value ] of Object . entries ( tagging ) ) {
2008
- fs_xattr [ XATTR_NOOBAA_CUSTOM_PREFIX + xattr_key ] = xattr_value ;
2008
+ fs_xattr [ XATTR_TAG + xattr_key ] = xattr_value ;
2009
2009
}
2010
2010
let file_path ;
2011
2011
if ( params . version_id && this . _is_versioning_enabled ( ) ) {
@@ -2017,7 +2017,7 @@ class NamespaceFS {
2017
2017
dbg . log0 ( 'NamespaceFS.put_object_tagging: fs_xattr ' , fs_xattr , 'file_path :' , file_path ) ;
2018
2018
try {
2019
2019
// remove existng tag before putting new tags
2020
- await this . _clear_user_xattr ( fs_context , file_path , XATTR_NOOBAA_CUSTOM_PREFIX ) ;
2020
+ await this . _clear_user_xattr ( fs_context , file_path , XATTR_TAG ) ;
2021
2021
await this . set_fs_xattr_op ( fs_context , file_path , fs_xattr , undefined ) ;
2022
2022
} catch ( err ) {
2023
2023
dbg . error ( `NamespaceFS.put_object_tagging: failed in dir ${ file_path } with error: ` , err ) ;
@@ -2316,6 +2316,10 @@ class NamespaceFS {
2316
2316
return xattr [ XATTR_MD5_KEY ] ;
2317
2317
}
2318
2318
2319
+ _number_of_tags_fs_xttr ( xattr ) {
2320
+ return Object . keys ( xattr ) . filter ( xattr_key => xattr_key . includes ( XATTR_TAG ) ) . length ;
2321
+ }
2322
+
2319
2323
/**
2320
2324
* @param {string } bucket
2321
2325
* @param {string } key
@@ -2336,6 +2340,7 @@ class NamespaceFS {
2336
2340
mime . getType ( key ) || 'application/octet-stream' ;
2337
2341
const storage_class = s3_utils . parse_storage_class ( stat . xattr ?. [ XATTR_STORAGE_CLASS_KEY ] ) ;
2338
2342
const size = Number ( stat . xattr ?. [ XATTR_DIR_CONTENT ] || stat . size ) ;
2343
+ const tag_count = stat . xattr ? this . _number_of_tags_fs_xttr ( stat . xattr ) : 0 ;
2339
2344
2340
2345
return {
2341
2346
obj_id : etag ,
@@ -2352,9 +2357,9 @@ class NamespaceFS {
2352
2357
storage_class,
2353
2358
restore_status : GlacierBackend . get_restore_status ( stat . xattr , new Date ( ) , this . _get_file_path ( { key} ) ) ,
2354
2359
xattr : to_xattr ( stat . xattr ) ,
2360
+ tag_count,
2355
2361
2356
2362
// temp:
2357
- tag_count : 0 ,
2358
2363
lock_settings : undefined ,
2359
2364
md5_b64 : undefined ,
2360
2365
num_parts : undefined ,
0 commit comments