@absolutejs/voice 0.0.22-beta.424 → 0.0.22-beta.426

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.
Files changed (2) hide show
  1. package/dist/index.js +27 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -28753,7 +28753,29 @@ var listRecentJsonFiles = async (directory, limit) => {
28753
28753
  }
28754
28754
  const indexedFiles = await readRecentJsonFileIndex(directory);
28755
28755
  if (indexedFiles.length >= limit) {
28756
- return indexedFiles.slice(0, limit).map((entry) => entry.path);
28756
+ const existingFiles = [];
28757
+ const missingPaths = new Set;
28758
+ for (const entry of indexedFiles) {
28759
+ try {
28760
+ await stat(entry.path);
28761
+ existingFiles.push(entry);
28762
+ if (existingFiles.length === limit) {
28763
+ break;
28764
+ }
28765
+ } catch (error) {
28766
+ if (error.code === "ENOENT") {
28767
+ missingPaths.add(entry.path);
28768
+ continue;
28769
+ }
28770
+ throw error;
28771
+ }
28772
+ }
28773
+ if (missingPaths.size > 0) {
28774
+ await writeRecentJsonFileIndex(directory, indexedFiles.filter((entry) => !missingPaths.has(entry.path)));
28775
+ }
28776
+ if (existingFiles.length === limit) {
28777
+ return existingFiles.map((entry) => entry.path);
28778
+ }
28757
28779
  }
28758
28780
  return (await rebuildRecentJsonFileIndex(directory)).slice(0, limit).map((entry) => entry.path);
28759
28781
  };
@@ -28774,10 +28796,13 @@ var writeRecentJsonFileIndex = async (directory, files) => {
28774
28796
  await mkdir3(directory, {
28775
28797
  recursive: true
28776
28798
  });
28777
- await writeFile(recentJsonFileIndexPath(directory), JSON.stringify({
28799
+ const path = recentJsonFileIndexPath(directory);
28800
+ const tempPath = `${path}.${crypto.randomUUID()}.tmp`;
28801
+ await writeFile(tempPath, JSON.stringify({
28778
28802
  files: sortRecentJsonFileIndexEntries(files).slice(0, 5000),
28779
28803
  version: 1
28780
28804
  }));
28805
+ await rename(tempPath, path);
28781
28806
  };
28782
28807
  var rebuildRecentJsonFileIndex = async (directory) => {
28783
28808
  const files = await listJsonFiles(directory);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@absolutejs/voice",
3
- "version": "0.0.22-beta.424",
3
+ "version": "0.0.22-beta.426",
4
4
  "description": "Voice primitives and Elysia plugin for AbsoluteJS",
5
5
  "repository": {
6
6
  "type": "git",