fix: file deletion logic to update recent files and handle errors #146

This commit is contained in:
Linus Rath
2026-04-03 14:20:06 +02:00
parent 5aad97d64e
commit c53ff5a30a
2 changed files with 21 additions and 3 deletions
+11 -1
View File
@@ -4153,6 +4153,7 @@ export class JMAPClient implements IJMAPClient {
[["FileNode/set", {
accountId,
destroy: ids,
onDestroyRemoveChildren: true,
}, "fns0"]],
this.fileUsing(),
);
@@ -4161,9 +4162,18 @@ export class JMAPClient implements IJMAPClient {
if (!result || result[0] === "error") {
throw new Error(result?.[1]?.description || "FileNode/set destroy failed");
}
const notDestroyedMap: Record<string, { type?: string; description?: string }> = result[1].notDestroyed || {};
const notDestroyedIds = Object.keys(notDestroyedMap);
if (notDestroyedIds.length > 0) {
const firstError = notDestroyedMap[notDestroyedIds[0]];
throw new Error(firstError?.description || `Failed to delete ${notDestroyedIds.length} file(s)`);
}
return {
destroyed: result[1].destroyed || [],
notDestroyed: result[1].notDestroyed ? Object.keys(result[1].notDestroyed) : [],
notDestroyed: [],
};
}