Skip to content

📝 Add docstrings to romy-lifecycle-filter-fail-on-internal-files-or-dirs #9074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions src/util/lifecycle_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,21 +133,23 @@ function build_expiration_header(rule, create_time) {
//////////////////

/**
* @typedef {{
* filter: Object
* expiration: Number
* }} filter_params
* Creates a filter function to determine if an object matches specified lifecycle criteria.
*
* builds lifecycle filter function
* 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.
*
* @param {filter_params} params
* @returns
* @param {filter_params} params - Lifecycle filter and expiration criteria.
* @returns {(object_info: Object) => boolean} A function that returns true if the object matches all lifecycle filter conditions.
*/
function build_lifecycle_filter(params) {
/**
* @param {Object} object_info
*/
return function(object_info) {
// fail if object is a temp file/part or a folder object or a versioned object
if (object_info.key.startsWith(config.NSFS_TEMP_DIR_NAME)) return false;
if (object_info.key.includes(config.NSFS_FOLDER_OBJECT_NAME)) return false;
if (object_info.key.includes('.versions/')) return false;

if (params.filter?.prefix && !object_info.key.startsWith(params.filter.prefix)) return false;
if (params.expiration && object_info.age < params.expiration) return false;
if (params.filter?.tags && !file_contain_tags(object_info, params.filter.tags)) return false;
Expand Down