Compare commits
1 Commits
developmen
...
user/jonat
Author | SHA1 | Date |
---|---|---|
Jonathan Gramain | c25a115da3 |
|
@ -30,6 +30,7 @@ class DelimiterVersions extends Delimiter {
|
|||
// internal state
|
||||
this.masterKey = undefined;
|
||||
this.masterVersionId = undefined;
|
||||
this.nullKey = null;
|
||||
// listing results
|
||||
this.NextMarker = parameters.keyMarker;
|
||||
this.NextVersionIdMarker = undefined;
|
||||
|
@ -190,10 +191,6 @@ class DelimiterVersions extends Delimiter {
|
|||
* @return {number} - indicates if iteration should continue
|
||||
*/
|
||||
filterV1(obj) {
|
||||
if (Version.isPHD(obj.value)) {
|
||||
// return accept to avoid skipping the next values in range
|
||||
return FILTER_ACCEPT;
|
||||
}
|
||||
// this function receives both M and V keys, but their prefix
|
||||
// length is the same so we can remove their prefix without
|
||||
// looking at the type of key
|
||||
|
@ -205,24 +202,13 @@ class DelimiterVersions extends Delimiter {
|
|||
if (this.prefix && !key.startsWith(this.prefix)) {
|
||||
return FILTER_SKIP;
|
||||
}
|
||||
let nonversionedKey;
|
||||
let versionId = undefined;
|
||||
const versionIdIndex = key.indexOf(VID_SEP);
|
||||
if (versionIdIndex < 0) {
|
||||
let nonversionedKey;
|
||||
if (versionIdIndex === -1) {
|
||||
nonversionedKey = key;
|
||||
this.masterKey = key;
|
||||
this.masterVersionId =
|
||||
Version.from(value).getVersionId() || 'null';
|
||||
versionId = this.masterVersionId;
|
||||
} else {
|
||||
nonversionedKey = key.slice(0, versionIdIndex);
|
||||
versionId = key.slice(versionIdIndex + 1);
|
||||
// skip a version key if it is the master version
|
||||
if (this.masterKey === nonversionedKey && this.masterVersionId === versionId) {
|
||||
return FILTER_SKIP;
|
||||
}
|
||||
this.masterKey = undefined;
|
||||
this.masterVersionId = undefined;
|
||||
}
|
||||
if (this.delimiter) {
|
||||
const baseIndex = this.prefix ? this.prefix.length : 0;
|
||||
|
@ -231,6 +217,49 @@ class DelimiterVersions extends Delimiter {
|
|||
return this.addCommonPrefix(nonversionedKey, delimiterIndex);
|
||||
}
|
||||
}
|
||||
if (versionIdIndex === -1) {
|
||||
this.masterKey = key;
|
||||
this.masterVersionId =
|
||||
Version.from(value).getVersionId() || 'null';
|
||||
versionId = this.masterVersionId;
|
||||
if (this.nullKey && this.nullKey.nonversionedKey !== key) {
|
||||
this.addContents({
|
||||
key: this.nullKey.nonversionedKey,
|
||||
value: this.nullKey.value,
|
||||
versionId: this.nullKey.versionId,
|
||||
});
|
||||
this.nullKey = null;
|
||||
}
|
||||
} else {
|
||||
versionId = key.slice(versionIdIndex + 1);
|
||||
// regular version key
|
||||
if (this.nullKey &&
|
||||
(this.nullKey.nonversionedKey !== nonversionedKey
|
||||
|| this.nullKey.versionId < versionId)) {
|
||||
this.addContents({
|
||||
key: this.nullKey.nonversionedKey,
|
||||
value: this.nullKey.value,
|
||||
versionId: this.nullKey.versionId,
|
||||
});
|
||||
this.nullKey = null;
|
||||
}
|
||||
if (versionId === '') {
|
||||
// null key
|
||||
versionId = Version.from(value).getVersionId();
|
||||
this.nullKey = {
|
||||
nonversionedKey,
|
||||
versionId,
|
||||
value,
|
||||
};
|
||||
return FILTER_ACCEPT;
|
||||
}
|
||||
if (this.masterKey === nonversionedKey && this.masterVersionId === versionId) {
|
||||
// do not add a version key if it is the master version
|
||||
return FILTER_SKIP;
|
||||
}
|
||||
this.masterKey = undefined;
|
||||
this.masterVersionId = undefined;
|
||||
}
|
||||
return this.addContents({ key: nonversionedKey, value, versionId });
|
||||
}
|
||||
|
||||
|
@ -268,6 +297,14 @@ class DelimiterVersions extends Delimiter {
|
|||
* specified in v1 listing documentation
|
||||
* http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGET.html
|
||||
*/
|
||||
if (this.nullKey) {
|
||||
this.addContents({
|
||||
key: this.nullKey.nonversionedKey,
|
||||
value: this.nullKey.value,
|
||||
versionId: this.nullKey.versionId,
|
||||
});
|
||||
this.nullKey = null;
|
||||
}
|
||||
return {
|
||||
CommonPrefixes: this.CommonPrefixes,
|
||||
Versions: this.Contents,
|
||||
|
|
Loading…
Reference in New Issue