Skip to content

fix: ensure new documents / drafts are also autosaved - #1802

Open
gi1242 wants to merge 1 commit into
flxzt:mainfrom
gi1242:autosave-drafts
Open

fix: ensure new documents / drafts are also autosaved#1802
gi1242 wants to merge 1 commit into
flxzt:mainfrom
gi1242:autosave-drafts

Conversation

@gi1242

@gi1242 gi1242 commented Jul 15, 2026

Copy link
Copy Markdown

When opening a new file, rnote won't autosave it until it's saved first. The default name is "New Document", and on tablets it's often a burden to choose a name and save it. So I often just work without saving the file initially. If there's a crash, then everything is lost.

I just implemented a fix:

  1. Offer a time/date based name for the file initially. (A user can jst save this in their workspace without having to think twice)
  2. Before the file has been officially saved, autosave the draft in ~/.cache/rnote/autosaves
  3. If the file is saved, then cleanup any autosaves in ~/.cache/rnote/autosaves
  4. On startup, if there are files in ~/.cache/rnote/autosaves, offer to load, delete or ignore them. (If the file is loaded, then it will be treated as a "new file" that is again autosaved as a draft in ~/.cache/rnote/autosaves. The old autosave will have to be deleted by the user (e.g. by choosing delete on the next run, or manually)

Fixes #545

@gi1242
gi1242 force-pushed the autosave-drafts branch from 54ab104 to d77b3cf Compare July 15, 2026 17:59
// --- AUTOSAVE RECOVERY CHECK ---
let input_file_clone = input_file.clone();
glib::spawn_future_local(clone!(#[weak] appwindow, async move {
let cache_dir = glib::user_cache_dir();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Can you add a function wrapping this invocation to env.rs? I want to have all functionality with regards to specific system and user directories collected there.


pub(crate) static OUTPUT_FILE_NEW_TITLE: once_cell::sync::Lazy<String> =
once_cell::sync::Lazy::new(|| gettext("New Document"));
once_cell::sync::Lazy::new(|| String::from("%Y%m%d-%H%M%S"));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does this fixes a single date for each rnote session ? I'm not convinced this is run once by canvas/new file (in which case it's better to remove the static and move the date logic where it's needed : here and in default_file_title_for_export)

@Doublonmousse

Copy link
Copy Markdown
Collaborator

Fixes #1592 as well

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.

auto save shall also save drafts

3 participants