Compare commits

..

No commits in common. "3d2e7ef072f275cd236a5a653d98525fc186680f" and "e446f202238719935da4f0de01bf96009a1b8374" have entirely different histories.

2 changed files with 1 additions and 104 deletions

View File

@ -1,4 +1,4 @@
export { default as StatsClient } from './StatsClient'; export { default as StatsClient } from './StatsClient';
export { default as StatsModel } from './StatsModel'; export { default as StatsModel } from './StatsModel';
export { default as RedisClient } from './RedisClient'; export { default as RedisClient } from './RedisClient';
export { default as ZenkoMetrics } from './ZenkoMetrics'; export { default as ZenkoMetrics } from './StatsClient';

View File

@ -223,109 +223,6 @@ class LifecycleUtils {
return applicableRules; return applicableRules;
/* eslint-enable no-param-reassign */ /* eslint-enable no-param-reassign */
} }
/**
* Helper method to determine if a version is a Delete Marker
* @param {Object} version - single version object
* @return {boolean} true/false
*/
_isDeleteMarker(version) {
// if no ETag, Size, and StorageClass, then it is a Delete Marker
return (
!Object.prototype.hasOwnProperty.call(version, 'ETag')
&& !Object.prototype.hasOwnProperty.call(version, 'Size')
&& !Object.prototype.hasOwnProperty.call(version, 'StorageClass')
);
}
/**
* check if rule applies for a given date or calculed days.
* @param {array} rule - bucket lifecycle rule
* @param {number} daysSinceInitiated - Days passed since entity (object or version) last modified
* NOTE: entity is not an in-progress MPU or a delete marker.
* @param {number} currentDate - current date
* @return {boolean} true if rule applies - false otherwise.
*/
_isRuleApplying(rule, daysSinceInitiated, currentDate) {
if (rule.Expiration && this._supportedRules.includes('expiration')) {
if (rule.Expiration.Days !== undefined && daysSinceInitiated >= rule.Expiration.Days) {
return true;
}
if (rule.Expiration.Date && rule.Expiration.Date < currentDate) {
return true;
}
// Expiration.ExpiredObjectDeleteMarker rule's action does not apply
// since object is not a delete marker.
// AbortIncompleteMultipartUpload.DaysAfterInitiation rule's action does not apply
// since in-progress MPUs are beeing handled separetly prior to this checks
}
if (rule.Transitions && rule.Transitions.length > 0
&& this._supportedRules.includes('transitions')) {
return rule.Transitions.some(t => {
if (t.Days !== undefined && daysSinceInitiated >= t.Days) {
return true;
}
if (t.Date && t.Date < currentDate) {
return true;
}
return false;
});
}
return false;
}
/**
* Check if entity (object or version) is eligible for expiration or transition
* This function was introduced to avoid having to go further into processing
* (call getObjectTagging, headObject...) if the entity was not eligible.
* @param {array} rules - array of bucket lifecycle rules
* @param {object} entity - object or object version
* NOTE: entity is not an in-progress MPU or a delete marker.
* @param {string} versioningStatus - 'Enabled', 'Suspended', or 'Disabled'
* @return {boolean} true if eligible - false otherwise.
*/
isEntityEligible(rules, entity, versioningStatus) {
const currentDate = this._datetime.getCurrentDate();
const daysSinceInitiated = this._datetime.findDaysSince(
new Date(entity.LastModified),
);
const { staleDate } = entity;
const daysSinceStaled = staleDate ?
this._datetime.findDaysSince(new Date(staleDate)) : null;
// Always eligible if object is a delete marker because
// delete marker might required extra s3 call (list versions).
if (this._isDeleteMarker(entity)) {
return true;
}
return rules.some(rule => {
if (versioningStatus === 'Enabled' || versioningStatus === 'Suspended') {
if (entity.IsLatest) {
return this._isRuleApplying(rule, daysSinceInitiated, currentDate);
}
if (!staleDate) {
// NOTE: this should never happen.
// If it is the case, we will log later for debug purposes.
return true;
}
if (rule.NoncurrentVersionExpiration
&& this._supportedRules.includes('noncurrentVersionExpiration')) {
if (rule.NoncurrentVersionExpiration.NoncurrentDays !== undefined &&
daysSinceStaled >= rule.NoncurrentVersionExpiration.NoncurrentDays) {
return true;
}
}
return false;
}
return this._isRuleApplying(rule, daysSinceInitiated, currentDate);
});
}
} }
module.exports = LifecycleUtils; module.exports = LifecycleUtils;