Skip to content

Commit

Permalink
ARSN-354 List lifecycle current versions supports V0 bucket format
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas2bert committed Jul 26, 2023
1 parent 218d910 commit 7becb8e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions lib/algos/list/delimiterCurrent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { Delimiter } = require('./delimiter');
const { DelimiterMaster } = require('./delimiterMaster');
const { FILTER_ACCEPT, FILTER_END } = require('./tools');

type ResultObject = {
Expand All @@ -16,7 +16,7 @@ const DELIMITER_TIMEOUT_MS = 10 * 1000; // 10s
* Handle object listing with parameters. This extends the base class Delimiter
* to return the master/current versions.
*/
class DelimiterCurrent extends Delimiter {
class DelimiterCurrent extends DelimiterMaster {
/**
* Delimiter listing of current versions.
* @param {Object} parameters - listing parameters
Expand Down Expand Up @@ -67,7 +67,7 @@ class DelimiterCurrent extends Delimiter {
return p;
}

filter(obj) {
addContents(key, value) {
if (this.start && Date.now() - this.start > DELIMITER_TIMEOUT_MS) {
this.IsTruncated = true;
this.logger.info('listing stopped after expected internal timeout',
Expand All @@ -78,22 +78,20 @@ class DelimiterCurrent extends Delimiter {
return FILTER_END;
}
++this.evaluatedKeys;

const parsedValue = this._parse(obj.value);
const parsedValue = this._parse(value);
// if parsing fails, skip the key.
if (parsedValue) {
const lastModified = parsedValue['last-modified'];
const dataStoreName = parsedValue.dataStoreName;
// We then check if the current version is older than the "beforeDate" and
// "excludedDataStoreName" is not specified or if specified and the data store name is different.
if ((!this.beforeDate || (lastModified && lastModified < this.beforeDate)) &&
(!this.excludedDataStoreName || dataStoreName !== this.excludedDataStoreName)) {
return super.filter(obj);
if ((!this.beforeDate || (lastModified && lastModified < this.beforeDate)) &&
(!this.excludedDataStoreName || dataStoreName !== this.excludedDataStoreName)) {
return super.addContents(key, value);
}
// In the event of a timeout occurring before any content is added,
// NextMarker is updated even if the object is not eligible.
// It minimizes the amount of data that the client needs to re-process if the request times out.
const key = this.getObjectKey(obj);
this.NextMarker = key;
}

Expand Down

0 comments on commit 7becb8e

Please sign in to comment.