Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: always delete vault references on vault deletion

Abdullah Attab4542a532bb6
diff --git a/packages/core/__tests__/vault.test.js b/packages/core/__tests__/vault.test.js
index be9fbdca7..dbdd0d2c8 100644
--- a/packages/core/__tests__/vault.test.js
+++ b/packages/core/__tests__/vault.test.js
@@ -185,7 +185,7 @@ test("delete vault without deleting all locked notes", () =>
await db.vault.delete();
- expect(await db.relations.from(vault, "note").has(id)).toBe(true);
+ expect(await db.relations.from(vault, "note").has(id)).toBe(false);
expect(await db.vaults.default()).toBeUndefined();
}));
diff --git a/packages/core/src/api/vault.ts b/packages/core/src/api/vault.ts
index ea1c7e199..8a663eaa2 100644
--- a/packages/core/src/api/vault.ts
+++ b/packages/core/src/api/vault.ts
@@ -160,7 +160,7 @@ export default class Vault {
await this.db.notes.remove(...lockedIds);
}
- await this.db.vaults.remove(vault.id, deleteAllLockedNotes);
+ await this.db.vaults.remove(vault.id);
this.password = undefined;
}
diff --git a/packages/core/src/collections/notes.ts b/packages/core/src/collections/notes.ts
index 61a684f91..4c0cae56f 100644
--- a/packages/core/src/collections/notes.ts
+++ b/packages/core/src/collections/notes.ts
@@ -138,7 +138,6 @@ export class Notes implements ICollection {
headline: headline,
pinned: item.pinned,
- locked: item.locked,
favorite: item.favorite,
localOnly: item.localOnly,
conflicted: item.conflicted,
diff --git a/packages/core/src/collections/vaults.ts b/packages/core/src/collections/vaults.ts
index 9703b5221..a8e761eb8 100644
--- a/packages/core/src/collections/vaults.ts
+++ b/packages/core/src/collections/vaults.ts
@@ -55,9 +55,9 @@ export class Vaults implements ICollection {
return id;
}
- async remove(id: string, unlinkAllNotes = false) {
+ async remove(id: string) {
await this.db.transaction(async () => {
- if (unlinkAllNotes) await this.db.relations.unlinkOfType("vault", [id]);
+ await this.db.relations.unlinkOfType("vault", [id]);
await this.collection.softDelete([id]);
});
}
diff --git a/packages/core/src/database/migrations.ts b/packages/core/src/database/migrations.ts
index 087f2bbe6..873c6ccfe 100644
--- a/packages/core/src/database/migrations.ts
+++ b/packages/core/src/database/migrations.ts
@@ -50,7 +50,6 @@ export class NNMigrationProvider implements MigrationProvider {
.addColumn("headline", "text")
.addColumn("contentId", "text")
.addColumn("pinned", "boolean")
- .addColumn("locked", "boolean")
.addColumn("favorite", "boolean")
.addColumn("localOnly", "boolean")
.addColumn("conflicted", "boolean")