Skip to content

Commit d13111b

Browse files
📝 Add docstrings to romy-lifecycle-filter-fail-on-internal-files-or-dirs
Docstrings generation was requested by @romayalon. * #9073 (comment) The following files were modified: * `src/util/lifecycle_utils.js`
1 parent 19d7a5a commit d13111b

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

‎src/util/lifecycle_utils.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,21 +133,23 @@ function build_expiration_header(rule, create_time) {
133133
//////////////////
134134

135135
/**
136-
* @typedef {{
137-
* filter: Object
138-
* expiration: Number
139-
* }} filter_params
136+
* Creates a filter function to determine if an object matches specified lifecycle criteria.
140137
*
141-
* builds lifecycle filter function
138+
* The returned function excludes temporary files, folder marker objects, and versioned objects before applying additional filter conditions such as prefix, minimum age, tag set, and object size constraints.
142139
*
143-
* @param {filter_params} params
144-
* @returns
140+
* @param {filter_params} params - Lifecycle filter and expiration criteria.
141+
* @returns {(object_info: Object) => boolean} A function that returns true if the object matches all lifecycle filter conditions.
145142
*/
146143
function build_lifecycle_filter(params) {
147144
/**
148145
* @param {Object} object_info
149146
*/
150147
return function(object_info) {
148+
// fail if object is a temp file/part or a folder object or a versioned object
149+
if (object_info.key.startsWith(config.NSFS_TEMP_DIR_NAME)) return false;
150+
if (object_info.key.includes(config.NSFS_FOLDER_OBJECT_NAME)) return false;
151+
if (object_info.key.includes('.versions/')) return false;
152+
151153
if (params.filter?.prefix && !object_info.key.startsWith(params.filter.prefix)) return false;
152154
if (params.expiration && object_info.age < params.expiration) return false;
153155
if (params.filter?.tags && !file_contain_tags(object_info, params.filter.tags)) return false;

0 commit comments

Comments
 (0)