@engine9-io/input-tools 1.9.8 → 1.9.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -734,7 +734,7 @@ Worker.prototype.listAll = async function ({ directory, start: s, end: e }) {
734
734
  if (e) end = relativeDate(e).getTime();
735
735
  if (directory.startsWith('s3://') || directory.startsWith('r2://')) {
736
736
  const worker = new (directory.startsWith('r2://') ? R2Worker : S3Worker)(this);
737
- return worker.listAll({ directory });
737
+ return worker.listAll({ directory, start, end });
738
738
  }
739
739
  const a = await fsp.readdir(directory, { recursive: true });
740
740
 
package/file/S3.js CHANGED
@@ -11,7 +11,7 @@ const {
11
11
  PutObjectCommand,
12
12
  ListObjectsV2Command
13
13
  } = require('@aws-sdk/client-s3');
14
- const { getTempFilename } = require('./tools');
14
+ const { getTempFilename, relativeDate } = require('./tools');
15
15
 
16
16
  function Worker() {
17
17
  this.prefix = 's3';
@@ -261,9 +261,12 @@ Worker.prototype.list.metadata = {
261
261
  }
262
262
  };
263
263
  /* List everything with the prefix */
264
- Worker.prototype.listAll = async function ({ directory }) {
264
+ Worker.prototype.listAll = async function (options) {
265
+ const { directory } = options;
265
266
  if (!directory) throw new Error('directory is required');
266
267
  let dir = directory;
268
+ const start = options.start && relativeDate(options.start);
269
+ const end = options.end && relativeDate(options.end);
267
270
  while (dir.slice(-1) === '/') dir = dir.slice(0, -1);
268
271
  const { Bucket, Key } = getParts(dir);
269
272
  const s3Client = this.getClient();
@@ -281,7 +284,16 @@ Worker.prototype.listAll = async function ({ directory }) {
281
284
  debug(`Sending List command with prefix ${Prefix} with ContinuationToken ${ContinuationToken}`);
282
285
 
283
286
  const result = await s3Client.send(command);
284
- const newFiles = result.Contents?.map((d) => `${this.prefix}://${Bucket}/${d.Key}`) || [];
287
+ const newFiles =
288
+ result.Contents?.filter(({ LastModified }) => {
289
+ if (start && new Date(LastModified) < start) {
290
+ return false;
291
+ } else if (end && new Date(LastModified) > end) {
292
+ return false;
293
+ } else {
294
+ return true;
295
+ }
296
+ })?.map((d) => `${this.prefix}://${Bucket}/${d.Key}`) || [];
285
297
  debug(`Retrieved ${newFiles.length} new files, total ${files.length},sample ${newFiles.slice(0, 3).join(',')}`);
286
298
  files.push(...newFiles);
287
299
  ContinuationToken = result.NextContinuationToken;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engine9-io/input-tools",
3
- "version": "1.9.8",
3
+ "version": "1.9.9",
4
4
  "description": "Tools for dealing with Engine9 inputs",
5
5
  "main": "index.js",
6
6
  "scripts": {