Enhancement: preserve note modified date when importing from Joplin - #3715
Merged
pbek merged 1 commit intoAug 31, 2026
Merged
Conversation
Joplin's raw export carries each note's real created_time/updated_time in its metadata block, but the importer never read it, so every imported note's file_last_modified ended up as "whenever the import ran" instead of the note's real history, breaking Note -> Sort by -> By date. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Owner
|
Thank you! |
pbek
added a commit
that referenced
this pull request
Aug 31, 2026
Signed-off-by: Patrizio Bekerle <patrizio@bekerle.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #3672. The Joplin importer currently doesn't try to preserve
a note's real modified date — every imported note's
file_last_modifiedends up as "whenever the import happened to write that file", so
Note -> Sort by -> By date(and search, which sorts the same list) can'treflect a note's actual history after import. For a large imported
collection this mostly reads as random. This PR adds that, written with
Claude Code.
The change is small.
importNote()already reads one field out of a note'sJoplin metadata block (
parent_id:, for subfolder placement) via a regexagainst the same
textvariable already in scope — this just adds asecond regex for
updated_time:(Joplin's ISO-8601-with-millisecondstimestamp, e.g.
2019-11-15T16:16:34.302Z, whichQDateTime::fromStringparses natively via
Qt::ISODateWithMs), and applies it to the file withQFile::setFileTime()as the very last step of the import, after all theexisting
storeNoteTextFileToDisk()calls so nothing overwrites itafterward. One thing worth flagging in review:
setFileTime()only takeseffect if the file is open when it's called — easy to miss, since it fails
silently otherwise.
setFileTime()needs Qt 5.10+; the project floor is Qt 5.5, so the wholeblock is behind a
QT_VERSION_CHECKguard (same pattern already usedelsewhere in this codebase, e.g.
linkdialog.cpp) — pre-5.10 Qt5 buildsjust skip the correction and keep today's behavior, nothing breaks.
Scoped to modified time only. Creation time seemed worth attempting too at
first, but most POSIX filesystems (Linux included) don't expose a way to
set birth time after the fact via the calls Qt/the OS provide, so it'd be
dead code there — and modified time is what actually drives the sorting
that motivated this.
Validation
Built and ran the enhanced importer's GUI against a synthetic repro export
(attached, 12 notes spanning 1998-2024). Currently, every imported note's
modified date collapses to the moment the import ran; with this change,
each one's file mtime (and the
file_last_modifiedthe app sorts by)matches its real Joplin
updated_time, confirmed down to correctUTC-to-local conversion.
Repro data
Small synthetic Joplin RAW export, no real data — 12 notes, each titled
like
Tag [2019-11-14] Doctor visit - lab results, spanning 1998-2024.The leading tag word is assigned in alphabetical order but in a note order
that's deliberately not chronological, so alphabetical-sort-order and
date-sort-order provably disagree — meaning correct sort order after import
demonstrates the change is reading each note's real date, not just
coincidentally reproducing title-string order. Attached as
repro-timestamps.zip. Import via "Import notes from Joplin"; currently,Note -> Sort by -> By datecomes out scrambled relative to the titles'dates, and with this change it reads in correct chronological order.
repro-timestamps.zip