mirror of
https://github.com/Dasemu/Synapse.git
synced 2026-11-26 15:26:17 +00:00
Settings screen (themes incl. Sweet, rebindable shortcuts), rich text escapes, page sidebar with the local graph, sortable All pages, tree view changes and the Type/Tags rows in the page header. Docs updated. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
4.3 KiB
4.3 KiB
Logseq import
Crate synapse-import: import_logseq(src, &graph, &ImportOptions, progress) -> Report.
CLI: cargo run --release -p synapse-import --example import -- <logseq_dir> <graph_dir> [--skip-existing] [--keep-legacy].
Pipeline
- Scan
pages/,journals/(.md,.org) andassets/(recursive). Settings are read fromlogseq/config.edn::journal/file-name-format,:journal/page-title-format,:file/name-format(:triple-lowbar→___is the namespace separator, otherwise.). - Assets: every file in
assets/is streamed into the blob store (put_asset_file, constant memory) keeping its original file name. - Parse (rayon): outline → block tree. Fractional positions via
position::between. - Pages, then aliases, then blocks, written on one thread.
Mapping
- File name → title:
a___b.md→a/b,%2F/url-encoding decoded. Atitle::page property overrides it. Journals2024_03_15.md→ journal page2024-03-15. [[Mar 15th, 2024]](configured title format) is rewritten to[[2024-03-15]].- Page properties = lines before the first bullet, YAML front matter, or a first block that holds
only properties.
alias::also registers aliases. Blockkey:: valuelines go to block properties (not the content);id::becomes the block id (so((uuid))refs keep working);collapsed:: truesets the flag. - Assets:
../assets/x%20y.png→asset://<blake3>in place (;?/#suffixes kept). Missing files are left as is and reported. - Logseq's organisational files
contents,card,favoritesandhls__*(PDF highlights) are skipped (ImportOptions::skip_legacy_pages, default on;--keep-legacyin the CLI); other built-in names (TODO,NOW, ...) import normally. Skipped paths go toReport::skipped_legacy, and empty stubs with those titles that refs created in this import are removed (pages that existed before are never touched). Purging other legacy pages is a manual action in the app (legacy_candidates/purge_pages). - Hubs (Synapse-only pages without blocks, see
architecture.md) are never written by a re-import: the file is skipped with a warning. .orgfiles: one raw root block per top-level heading, no parsing; listed inReport::org_files.- Timestamps: page
created_at= file birth time (≤ mtime),updated_at= mtime; blocks inherit them.origin_journal= earliest journal referencing the page (aliases resolved), else the file's creation day. Journal pages keep core's midnight timestamps.
Re-import and native content
The importer records what it wrote in two local tables (import_pages: source file → page id,
import_blocks: block id → state hash). Re-imports use them so Synapse content is never lost:
- Pages are found by source file first, so a page renamed in Synapse is updated, not duplicated.
- Block ids: Logseq
id::when present, otherwise UUIDv5 of (source file, parent id, content, duplicate index). Inserting or moving a block elsewhere in a file does not change other ids. - Only blocks the importer wrote are ever overwritten or deleted, and only while unedited in Synapse. Edited blocks keep the Synapse version (warning if the file changed too); a removed block that was edited or has native children is kept (warning). Native blocks are never touched.
- First import into an existing page (e.g. today's journal) appends the imported blocks after the native ones; page properties are merged without overriding existing keys.
- A block deleted in Synapse stays deleted unless the file changed it.
- Each document is written in its own savepoint; a failure rolls the document back and becomes a warning. The whole write phase is one transaction.
ExistingPages::Skipleaves any page that already has blocks alone.
Report / progress
Progress { phase, done, total } (phases: Scanning, Assets, Parsing, Pages, Blocks) and
Report { pages, journals, blocks, assets, bytes, updated, unchanged, org_files, skipped_legacy, warnings }.
Known limits
- Not parsed: org-mode syntax, whiteboards,
draws/, namespace parent stubs, Logseq queries. - Speed is bound by core's per-block savepoint inside the import transaction: 208k blocks (10k pages) ≈ 60 s; re-importing an unchanged graph ≈ 1.3 s.