@telecrypt-io/storage 0.5.11 → 0.5.18

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.
@@ -987,6 +987,7 @@ export async function listFiles(storage, treeId, options) {
987
987
  export async function listSubfolders(storage, parentId, options) {
988
988
  return withOperationDeadline(options, async (signal) => {
989
989
  const tree = await resolveTree(storage, parentId, signal);
990
+ await storage.refreshRoomState(parentId, { signal });
990
991
  ensureOperationActive(signal);
991
992
  const directories = tree.getDirectories();
992
993
  if (directories.length > MAX_LIST_ITEMS)
@@ -1291,6 +1292,20 @@ export async function deleteFile(storage, treeId, fileId, options) {
1291
1292
  }
1292
1293
  throw new MutationPartialError("delete file", completedIds, "media was deleted but Matrix event cleanup stopped");
1293
1294
  }
1295
+ try {
1296
+ await waitForCondition(async () => {
1297
+ await storage.refreshRoomState(tree.id, { signal });
1298
+ ensureOperationActive(signal);
1299
+ const current = tree.getFile(fileId);
1300
+ return !current || !current.isActive ? true : null;
1301
+ }, { timeoutMs: 15000, signal });
1302
+ }
1303
+ catch (error) {
1304
+ if (error instanceof MutationOutcomeUnknownError)
1305
+ throw error;
1306
+ const detail = "Matrix deletion completed but the inactive file state could not be verified";
1307
+ throw new MutationPartialError("delete file", completedIds, detail);
1308
+ }
1294
1309
  ensureOperationActive(signal);
1295
1310
  return { id: fileId, deleted: true };
1296
1311
  }, "mutation");
@@ -1307,6 +1322,25 @@ export async function uploadFile(storage, treeId, name, bytes, mimetype, options
1307
1322
  throw new StorageError("operation cancelled");
1308
1323
  throw new StorageError("upload failed");
1309
1324
  });
1325
+ // The create-file request is acknowledged before the event necessarily
1326
+ // arrives in this client's sync timeline. A caller can otherwise report a
1327
+ // successful folder upload and immediately list a missing nested file.
1328
+ try {
1329
+ await waitForCondition(async () => {
1330
+ // Refresh the joined room's authoritative state before checking the
1331
+ // local tree. The sync loop carries timeline file events, while this
1332
+ // refresh closes the state lag for the room being uploaded into.
1333
+ await storage.refreshRoomState(tree.id, { signal });
1334
+ ensureOperationActive(signal);
1335
+ const file = tree.getFile(fileId);
1336
+ return file?.isActive ? file : null;
1337
+ }, { timeoutMs: 15000, signal });
1338
+ }
1339
+ catch (error) {
1340
+ if (error instanceof MutationOutcomeUnknownError)
1341
+ throw error;
1342
+ throw new MutationPartialError("upload file", [fileId], "upload completed but the file could not be observed locally");
1343
+ }
1310
1344
  ensureOperationActive(signal);
1311
1345
  return { id: fileId, name, mimetype };
1312
1346
  }, "mutation");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telecrypt-io/storage",
3
- "version": "0.5.11",
3
+ "version": "0.5.18",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.19.0",