Skip to content

fix: import Windows and HTTPS linked PDF annotations - #13162

Merged
tiensonqin merged 4 commits into
masterfrom
logseq/fix-windows-https-pdf-import-84dc
Sep 8, 2026
Merged

tiensonqin merged 4 commits into
masterfrom
logseq/fix-windows-https-pdf-import-84dc

Conversation

@tiensonqin

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1140 (follow-up to db-test#923 / PR #12815).

Root cause

File→DB import (import-file-graph-to-db / import-linked-file-pdf-annotations) only treated mldoc Complex links with protocol=file as PDF assets, and ensure-asset-data! dropped the asset when <get-file-stat> failed.

  • ![x](https://….pdf) never entered asset-links.
  • file://D:\… entered asset-links and resolved to a drive path, then failed the local stat and created no Asset.
  • hls__ pages store file:: / file-path:: without importing the page, so a remote PDF referenced only there also produced no Asset.
  • Without an Asset, :logseq.class/Pdf-annotation blocks could not bind :logseq.property/asset.

Fix

  • Accept http/https Complex PDF links in AST walking, matching the 2个css相关问题—引用格式字体偏大;右侧滚动条背景色 #923 POSIX file:// path.
  • Create a stub Asset for external file:// (including Windows drive URIs) and remote https:// PDFs when the file is missing or non-local. Keep the original URL as :logseq.property.asset/external-url.
  • Also create Assets from hls__ page file:: / file-path:: PDF targets.
  • Leave missing in-graph relative PDFs (../assets/missing.pdf) ignored, and do not change the 100MB asset size limit.

Tests

Hermetic tmpdir fixtures in deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs:

  • import-windows-linked-pdf-uri-format — file://D:\assets\LocalDoc.pdf creates an Asset and binds annotations
  • import-remote-https-pdf-annotations — https://example.com/RemoteDoc.pdf image target creates a bindable Asset
  • import-remote-https-pdf-annotations-from-hls-file-prop — HTTPS file:: only (no image) still creates and binds the Asset

Existing POSIX linked-PDF, uppercase-extension, and missing-relative-PDF tests still pass. Full non-integration exporter suite: 43 tests, 358 assertions, 0 failures.

Open in Web Open in Cursor 

Copilot AI lite review requested due to automatic review settings September 2, 2026 17:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

It changes core import behavior (asset detection + asset creation + per-file import flow) in ways that can affect broader importer correctness beyond the covered cases.

Pull request overview

This PR fixes File→DB import of linked PDF annotations when the PDF is referenced via Windows drive file:// URIs or remote http(s):// URLs, including cases where the only PDF reference lives in hls__ annotation page properties, so imported :logseq.class/Pdf-annotation blocks can reliably bind to a corresponding Asset.

Changes:

  • Extend AST asset-link detection to treat http/https Complex links to PDFs as importable PDF assets (in addition to file).
  • Create stub external Asset entries for remote http(s):// PDFs and for external/missing file:// PDFs (including Windows drive URIs) so annotations can still bind.
  • Add hermetic regression tests for Windows drive URIs, remote HTTPS image links, and HTTPS targets referenced only via hls__ file:: / file-path:: properties; document the audited case.
File summaries
File Description
docs/og_import_graph_cases.md Documents the newly supported Windows/HTTPS linked-PDF annotation import case and references new regression tests.
deps/graph-parser/test/logseq/graph_parser/exporter_test.cljs Adds hermetic tmpdir fixtures and async tests covering Windows file:// URIs, remote HTTPS PDFs, and hls__-property-only PDF targets.
deps/graph-parser/src/logseq/graph_parser/exporter.cljs Updates asset-link URL reconstruction, ensures stub Asset creation for external PDFs, and imports assets derived from hls__ file properties.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/og_import_graph_cases.md Resolved
@megayu
megayu force-pushed the logseq/fix-windows-https-pdf-import-84dc branch from 7cf70dc to 0947963 Compare September 7, 2026 07:37
cursoragent and others added 4 commits September 8, 2026 10:11
Create Asset stubs for file:// drive-letter URIs and remote https PDF
links during file-to-DB import so Pdf-annotation blocks can bind
:logseq.property/asset. Keep missing in-graph relative PDFs ignored.

Co-authored-by: Tienson Qin <[email protected]>
Simplify PDF detection and consolidate annotation import coverage. Normalize temporary graph paths on Windows to fix existing test failures.
Map promesa.core/doseq like the root config so export-doc-files lint
stops treating annotation-file bindings as unresolved symbols.

Co-authored-by: Tienson Qin <[email protected]>
@tiensonqin
tiensonqin force-pushed the logseq/fix-windows-https-pdf-import-84dc branch from 3f58996 to e416785 Compare September 8, 2026 02:11
@tiensonqin
tiensonqin merged commit 323392f into master Sep 8, 2026
18 checks passed
@tiensonqin
tiensonqin deleted the logseq/fix-windows-https-pdf-import-84dc branch September 8, 2026 02:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants