@telecrypt-io/storage 0.5.25 → 0.5.26

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.
@@ -248,7 +248,8 @@ function assertTreeEmptyForDeletion(storage, tree, spaces) {
248
248
  try {
249
249
  files = tree
250
250
  .listAllFiles()
251
- .filter((file) => !isMarkedFileDeleted(storage, tree.id, file.id));
251
+ .filter((file) => !isMarkedFileDeleted(storage, tree.id, file.id) &&
252
+ !isConfirmedDeletedFile(storage.getClient(), tree.id, file));
252
253
  }
253
254
  catch {
254
255
  throw new StorageError("could not enumerate storage files safely");
@@ -333,6 +334,26 @@ function isActiveRelationEvent(event) {
333
334
  !Array.isArray(content) &&
334
335
  Object.keys(content).length > 0);
335
336
  }
337
+ /**
338
+ * A deleted MSC3089 branch is represented by an authoritative empty state
339
+ * event. Inactive branches with metadata are historical versions, and a
340
+ * missing or malformed state cannot prove that the file was deleted.
341
+ */
342
+ function isConfirmedDeletedFile(client, treeId, file) {
343
+ if (file.isActive)
344
+ return false;
345
+ const stateEvents = readRelationEvents(client, treeId, UNSTABLE_MSC3089_BRANCH.name, file.id);
346
+ if (!stateEvents || stateEvents.length !== 1)
347
+ return false;
348
+ const stateEvent = stateEvents[0];
349
+ if (relationStateKey(stateEvent) !== file.id)
350
+ return false;
351
+ const content = stateEvent.getContent?.();
352
+ return (typeof content === "object" &&
353
+ content !== null &&
354
+ !Array.isArray(content) &&
355
+ Object.keys(content).length === 0);
356
+ }
336
357
  /**
337
358
  * Deletion is intentionally narrower than MSC3089TreeSpace.delete(): a local
338
359
  * child graph is not proof that the rooms are exclusively owned by this tree.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telecrypt-io/storage",
3
- "version": "0.5.25",
3
+ "version": "0.5.26",
4
4
  "license": "BUSL-1.1",
5
5
  "type": "module",
6
6
  "packageManager": "npm@11.19.0",