@engine9-io/input-tools 1.9.6 → 1.9.8

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.
@@ -769,9 +769,12 @@ Worker.prototype.listAll = async function ({ directory, start: s, end: e }) {
769
769
  };
770
770
  Worker.prototype.listAll.metadata = {
771
771
  options: {
772
- directory: { required: true }
772
+ directory: { required: true },
773
+ start: {},
774
+ end: {}
773
775
  }
774
776
  };
777
+
775
778
  Worker.prototype.moveAll = async function (options) {
776
779
  const { directory, targetDirectory } = options;
777
780
  if (!directory) throw new Error('directory is required');
@@ -821,6 +824,23 @@ Worker.prototype.empty.metadata = {
821
824
  }
822
825
  };
823
826
 
827
+ Worker.prototype.removeAll = async function (options) {
828
+ const filenames = await this.listAll(options);
829
+
830
+ const pLimit = await import('p-limit');
831
+
832
+ const limitedMethod = pLimit.default(10);
833
+
834
+ return Promise.all(filenames.map((filename) => limitedMethod(async () => this.remove({ filename }))));
835
+ };
836
+ Worker.prototype.removeAll.metadata = {
837
+ options: {
838
+ directory: { required: true },
839
+ start: {},
840
+ end: {}
841
+ }
842
+ };
843
+
824
844
  Worker.prototype.remove = async function ({ filename }) {
825
845
  if (!filename) throw new Error('filename is required');
826
846
  if (typeof filename !== 'string') throw new Error(`filename isn't a string:${JSON.stringify(filename)}`);
@@ -874,7 +894,14 @@ Worker.prototype.move = async function ({ filename, target, remove = true }) {
874
894
  }
875
895
  await fsp.mkdir(path.dirname(target), { recursive: true });
876
896
  if (remove) {
877
- await fsp.rename(filename, target);
897
+ try {
898
+ await fsp.rename(filename, target);
899
+ } catch (e) {
900
+ //it may be a filesystem issue moving between items
901
+ debug('Assuming this is a filesystem crosslink error, ignoring ', e.getMessage());
902
+ await fsp.copyFile(filename, target);
903
+ await fsp.unlink(filename);
904
+ }
878
905
  } else {
879
906
  await fsp.copyFile(filename, target);
880
907
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@engine9-io/input-tools",
3
- "version": "1.9.6",
3
+ "version": "1.9.8",
4
4
  "description": "Tools for dealing with Engine9 inputs",
5
5
  "main": "index.js",
6
6
  "scripts": {