flxzt/rnote · error · anyhow::Error

Failed to reload file from disk, no file path saved.

Error message

Failed to reload file from disk, no file path saved.

What it means

reload_from_disk re-reads the document from its saved origin file. The canvas tracks the output file as Option; when the document has never been saved (no origin path), output_file() is None and this error is thrown, since there is nothing to reload from.

Solutions

  1. Only enable the reload/revert action when the document has an output file (check output_file().is_some() and desensitize the action otherwise).
  2. Treat None as a no-op: return Ok(()) with a log instead of an error when there is no origin file.
  3. Save the document first (dialog_save_doc_as) to establish an output path before allowing reload.

Example fix

// before
let Some(output_file) = self.output_file() else {
    return Err(anyhow::anyhow!(
        "Failed to reload file from disk, no file path saved."
    ));
};
// after
let Some(output_file) = self.output_file() else {
    log::debug!("reload_from_disk: no origin file, nothing to reload");
    return Ok(());
};
Defensive patterns

Strategy: validation

Validate before calling

// rust
if canvas.output_file().is_none() {
    eprintln!("document has no origin file; save it first before reload");
}

Type guard

fn can_reload(canvas: &RnCanvas) -> bool { canvas.output_file().is_some() }

Try / catch

if let Err(e) = canvas.reload_from_disk().await {
    if e.to_string().contains("no file path saved") {
        // offer save-as instead
        dialogs::canvas::dialog_save_doc_as(&appwindow).await?;
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: Calling reload_from_disk (e.g. 'Revert to saved' action, or a file-change watcher) on a canvas whose output_file was never set — an unsaved/new document, or one created from bytes without an origin file.

Common situations: User hits revert on an untitled note; autosave/conflict-resync logic reloading a doc that was never written to disk; reloading after opening a file through a pathless source that failed to set output_file.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08). Data as JSON: /api/errors/3b5a48d50f2b8222. Report an issue: GitHub.

Appendix: source

Thrown at crates/rnote-ui/src/canvas/imexport.rs:51

        let mut widget_flags = self.engine_mut().load_snapshot(engine_snapshot);
        widget_flags |= self
            .engine_mut()
            .set_scale_factor(self.scale_factor() as f64);

        self.set_output_file(file_path.map(gio::File::for_path));
        self.dismiss_output_file_modified_toast();
        self.set_unsaved_changes(false);
        self.set_empty(false);

        Ok(widget_flags)
    }

    /// Reload the engine from the file that is set as origin file.
    ///
    /// If the origin file is set to None, this does nothing and returns an error.
    pub(crate) async fn reload_from_disk(&self) -> anyhow::Result<()> {
        let Some(output_file) = self.output_file() else {
            return Err(anyhow::anyhow!(
                "Failed to reload file from disk, no file path saved."
            ));
        };
        let (bytes, _) = output_file.load_bytes_future().await?;
        let widget_flags = self
            .load_in_rnote_bytes(bytes.to_vec(), output_file.path())
            .await?;
        self.emit_handle_widget_flags(widget_flags);
        Ok(())
    }

    pub(crate) async fn load_in_xopp_bytes(
        &self,
        appwindow: &RnAppWindow,
        bytes: Vec<u8>,
    ) -> anyhow::Result<()> {
        let xopp_import_prefs = appwindow
            .engine_config()

View on GitHub (pinned to bbc5354502)