@@ -21,7 +21,7 @@ const STORAGE_CLASS_GLACIER = 'GLACIER'; // "S3 Glacier Flexible Retrieval"
2121/** @type {nb.StorageClass } */
2222const STORAGE_CLASS_GLACIER_IR = 'GLACIER_IR' ; // "S3 Glacier Instant Retrieval"
2323/** @type {nb.StorageClass } */
24- const STORAGE_CLASS_GLACIER_DA = 'GLACIER_DA ' ; // "DBS3 specific Storage Class"
24+ const STORAGE_CLASS_DEEP_ARCHIVE = 'DEEP_ARCHIVE ' ; // "S3 Deep Archive Storage Class"
2525
2626const DEFAULT_S3_USER = Object . freeze ( {
2727 ID : '123' ,
@@ -44,6 +44,17 @@ const X_NOOBAA_AVAILABLE_STORAGE_CLASSES = 'x-noobaa-available-storage-classes';
4444const OBJECT_ATTRIBUTES = Object . freeze ( [ 'ETag' , 'Checksum' , 'ObjectParts' , 'StorageClass' , 'ObjectSize' ] ) ;
4545const OBJECT_ATTRIBUTES_UNSUPPORTED = Object . freeze ( [ 'Checksum' , 'ObjectParts' ] ) ;
4646
47+ /**
48+ * Set of storage classes which support RestoreObject S3 API
49+ *
50+ * GLACIER_IR is omitted as it doesn't require a restore.
51+ * @type {nb.StorageClass[] }
52+ */
53+ const GLACIER_STORAGE_CLASSES = [
54+ STORAGE_CLASS_GLACIER ,
55+ STORAGE_CLASS_DEEP_ARCHIVE ,
56+ ] ;
57+
4758 /**
4859 * get_default_object_owner returns bucket_owner info if exists
4960 * else it'll return the default owner
@@ -381,10 +392,12 @@ function parse_storage_class_header(req) {
381392 * @returns {nb.StorageClass }
382393 */
383394function parse_storage_class ( storage_class ) {
384- if ( ! storage_class ) return STORAGE_CLASS_STANDARD ;
385- if ( storage_class === STORAGE_CLASS_STANDARD ) return STORAGE_CLASS_STANDARD ;
395+ if ( config . NSFS_GLACIER_FORCE_STORAGE_CLASS ) {
396+ storage_class = config . NSFS_GLACIER_FORCE_STORAGE_CLASS ;
397+ }
398+ if ( ! storage_class || storage_class === STORAGE_CLASS_STANDARD ) return STORAGE_CLASS_STANDARD ;
386399 if ( storage_class === STORAGE_CLASS_GLACIER ) return STORAGE_CLASS_GLACIER ;
387- if ( storage_class === STORAGE_CLASS_GLACIER_DA ) return STORAGE_CLASS_GLACIER_DA ;
400+ if ( storage_class === STORAGE_CLASS_DEEP_ARCHIVE ) return STORAGE_CLASS_DEEP_ARCHIVE ;
388401 if ( storage_class === STORAGE_CLASS_GLACIER_IR ) return STORAGE_CLASS_GLACIER_IR ;
389402 throw new Error ( `No such s3 storage class ${ storage_class } ` ) ;
390403}
@@ -822,19 +835,11 @@ function parse_body_public_access_block(req) {
822835 return parsed ;
823836}
824837
825- function override_storage_class ( req ) {
826- if (
827- config . NSFS_GLACIER_FORCE_STORAGE_CLASS &&
828- parse_storage_class_header ( req ) === STORAGE_CLASS_STANDARD
829- ) {
830- req . headers [ 'x-amz-storage-class' ] = STORAGE_CLASS_GLACIER ;
831- }
832- }
833838
834839exports . STORAGE_CLASS_STANDARD = STORAGE_CLASS_STANDARD ;
835840exports . STORAGE_CLASS_GLACIER = STORAGE_CLASS_GLACIER ;
836841exports . STORAGE_CLASS_GLACIER_IR = STORAGE_CLASS_GLACIER_IR ;
837- exports . STORAGE_CLASS_GLACIER_DA = STORAGE_CLASS_GLACIER_DA ;
842+ exports . STORAGE_CLASS_DEEP_ARCHIVE = STORAGE_CLASS_DEEP_ARCHIVE ;
838843exports . DEFAULT_S3_USER = DEFAULT_S3_USER ;
839844exports . DEFAULT_OBJECT_ACL = DEFAULT_OBJECT_ACL ;
840845exports . decode_chunked_upload = decode_chunked_upload ;
@@ -876,6 +881,6 @@ exports.key_marker_to_cont_tok = key_marker_to_cont_tok;
876881exports . parse_sse_c = parse_sse_c ;
877882exports . verify_string_byte_length = verify_string_byte_length ;
878883exports . parse_body_public_access_block = parse_body_public_access_block ;
879- exports . override_storage_class = override_storage_class ;
880884exports . OBJECT_ATTRIBUTES = OBJECT_ATTRIBUTES ;
881885exports . OBJECT_ATTRIBUTES_UNSUPPORTED = OBJECT_ATTRIBUTES_UNSUPPORTED ;
886+ exports . GLACIER_STORAGE_CLASSES = GLACIER_STORAGE_CLASSES ;
0 commit comments