fix(import): preserve file and journal mention timestamps by tiensonqin · Pull Request #13148 · logseq/logseq · GitHub
Skip to content

fix(import): preserve file and journal mention timestamps - #13148

Open
tiensonqin wants to merge 14 commits into
masterfrom
logseq/fix-import-timestamps-a745
Open

fix(import): preserve file and journal mention timestamps#13148
tiensonqin wants to merge 14 commits into
masterfrom
logseq/fix-import-timestamps-a745

Conversation

@tiensonqin

@tiensonqin tiensonqin commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Fixes logseq/db-test#1047

Builds on #13032 so file-to-DB import keeps source timestamps instead of the import time.

Behavior change

  • File-backed pages prefer filesystem birthtime for created-at when it is a real positive time.
  • Missing or invalid birthtime (including Linux ext4 epoch-0) falls back to mtime / File.lastModified.
  • A page that already has file timestamps keeps those times when a journal later mentions it.
  • Journal pages and their blocks keep the journal day, even when the journal file has filesystem stats.
  • UI import serializes those timestamps onto each file before the worker runs (<get-file-stat is nil in the worker).
  • When a page is first created as a reference and later imported from its own file, that file's created/updated timestamps overwrite the first-mention timestamps only when real file stats exist.
  • Pages that only exist because they were linked from a journal use that journal file's date, even if the journal also links another date or has filesystem timestamps.
  • File-backed pages that mention a journal date keep their own filesystem timestamps.

Tests

Reproduced the db-test#1047 conversation cases plus review regressions in deps/graph-parser nbb tests.

OG IndexedDB created/updated columns (discussed on the issue) are not imported. Those values are not stored in the file graph.

Open in Web Open in Cursor 

megayu and others added 6 commits August 17, 2026 10:41
… logseq/fix-import-timestamps-a745

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Preserve source timestamps through UI import, overwrite file-backed
pages after first mention, and use the first journal date for pages
that only exist as references. Coerce Date and epoch-ms values
without crashing on numbers or Linux epoch-0 birthtime.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Extract stamps reference pages with import time, so missing-timestamp
fill never saw a blank created-at. Overwrite those stamps for
non-journal named pages created from a journal, and use mtime when
birthtime is missing or epoch 0.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
@tiensonqin
tiensonqin marked this pull request as ready for review August 31, 2026 17:20
Copilot AI lite review requested due to automatic review settings August 31, 2026 17:20

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

cursoragent and others added 8 commits August 31, 2026 17:22
Use the current journal filename for first-mention timestamps instead
of counting extracted journal-day pages. Keep filesystem times on
file-backed pages, and do not overwrite an earlier journal mention
when the later page file has no stats.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Use a real birthtime for created-at when present. Fall back to mtime when birthtime is missing or invalid.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Prefer a file page's birthtime, or mtime when birthtime is missing, over the journal mention date.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Look up pages already in the db so a later journal mention does not recreate them or replace file timestamps.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
User pages like alias must not collide with built-in schema pages during import.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Rename the existing-page lookup so it does not shadow a local, and drop the German heading that typos flagged.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
File birthtime/mtime must not replace a journal page's created-at. Journal files stay on their journal day.

Co-authored-by: Tienson Qin <tiensonqin@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some pages have wrong creation and update date after import

4 participants