mirror of
https://github.com/narrrl/narl-workspace.git
synced 2026-11-03 16:41:27 +01:00
integrity: one write, one transaction, and nothing left behind
Node update, delete and move each ran as separate statements, with the slug chosen outside the write that took it. They are now one transaction each, opened with BEGIN IMMEDIATE so a read-then-write cannot fail with SQLITE_BUSY halfway. Creating a node, a space or a file does the same. A delete is one function, delete_subtree, used by the API and the SFTP mount alike: SFTP deletes used to skip the media cleanup and orphan the files a document embedded. Rows go in the transaction, bytes after the commit. Deleting a media row that backs a file in the tree is refused; the media browser marks those files and stops counting them as documents that embed them. A space can no longer be moved into a folder. The diary is found by a role column (migration 0013) instead of its slug, so renaming it no longer breaks the reminder or the agenda, and it cannot be deleted. The same migration adds the unique index root slugs never had. A card is done exactly when it is in the last list: a done patch now moves the card, a card made in the done list is stamped, and adding or deleting lists settles the board. Seeding a fresh board is atomic, and a card links only to a document. Uploads are fsynced before the rename, and zip entries are written aside and renamed like any other upload. A sweep at start and once a day removes leftover .part files, files no row knows, and uploads nothing has embedded for a week. Before a new build migrates the database it writes a VACUUM INTO copy, diary.db.pre-<version>, since migrations only go forward.
This commit is contained in:
1 parent
082f2c8602
commit
e1d696701f
16 files changed
+812
-182
No files matched your search
+5
-1
@@ -23,6 +23,8 @@ export interface NodeSummary {
|
||||
excerpt: string
|
||||
position: number
|
||||
has_board: boolean
|
||||
/** Spaces the app has to tell apart: `diary`, or nothing. */
|
||||
role: string | null
|
||||
child_count: number
|
||||
created_at: number
|
||||
updated_at: number
|
||||
@@ -45,13 +47,13 @@ export interface WorkspaceNode extends NodeSummary {
|
||||
path: Crumb[]
|
||||
}
|
||||
|
||||
/** A public key allowed to mount the workspace over SFTP. */
|
||||
/** A space as the overview shows it: itself, and what was last written in it. */
|
||||
export interface SpaceOverview {
|
||||
space: NodeSummary
|
||||
recent: NodeSummary[]
|
||||
}
|
||||
|
||||
/** A public key allowed to mount the workspace over SFTP. */
|
||||
export interface SshKey {
|
||||
id: number
|
||||
name: string
|
||||
@@ -130,6 +132,8 @@ export interface MediaFile {
|
||||
encrypted: boolean
|
||||
/** Every document that embeds this file — a file may be used by several. */
|
||||
node_ids: number[]
|
||||
/** The file node it is, when it sits in the tree; deleted from there. */
|
||||
file_node: number | null
|
||||
}
|
||||
|
||||
/** The vault, as `/api/vault` reports it. */
|
||||
|
||||
Reference in new issue
Block a user