Skip to content

Commit

Permalink
feat: Add fetchOnlyRelevantRevisions config option when activating
Browse files Browse the repository at this point in the history
If you set this option in your S3 config then we will only load enough revisions from
S3 to find the currently active version and then we will stop.
The assumption here is that the main use-case for `fetchInitialRevisions` is to be
able to do some sort of changelog or audit log from another plugin where we would
want to know the details of the previously active revision.
Since looping over revisions from S3 can be slow when you have too many of them
stored (see ember-cli-deploy#120) we provide an option to short circuit that.
  • Loading branch information
Kelvin Luck committed Jul 4, 2022
1 parent ccfd427 commit 8000d88
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ module.exports = {
},

fetchInitialRevisions: function(context) {

if (this.readConfig('fetchOnlyRelevantRevisions')) {
this.log('fetchInitialRevisions - fetching only enough revisions to find the active revision', { verbose: true });
return this._fetchActiveRevision();
}

return this._list(context)
.then(function(revisions) {
return {
Expand All @@ -124,6 +130,24 @@ module.exports = {
});
},

_fetchActiveRevision: function() {
var bucket = this.readConfig('bucket');
var prefix = this.readConfig('prefix');
var filePattern = this.readConfig('filePattern');

var options = {
bucket: bucket,
prefix: prefix,
filePattern: filePattern,
};

var s3 = new this.S3({ plugin: this });
return s3.getActiveRevision(options)
.then((activeRevision) => {
return { initialRevisions: [activeRevision] };
});
},

_list: function(/* context */) {
var bucket = this.readConfig('bucket');
var prefix = this.readConfig('prefix');
Expand Down

0 comments on commit 8000d88

Please sign in to comment.