{"record":{"id":"3b5a48d50f2b8222","repo":"flxzt/rnote","slug":"failed-to-reload-file-from-disk-no-file-path-save","errorCode":null,"errorMessage":"Failed to reload file from disk, no file path saved.","messagePattern":"Failed to reload file from disk, no file path saved\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/rnote-ui/src/canvas/imexport.rs","lineNumber":51,"sourceCode":"        let mut widget_flags = self.engine_mut().load_snapshot(engine_snapshot);\n        widget_flags |= self\n            .engine_mut()\n            .set_scale_factor(self.scale_factor() as f64);\n\n        self.set_output_file(file_path.map(gio::File::for_path));\n        self.dismiss_output_file_modified_toast();\n        self.set_unsaved_changes(false);\n        self.set_empty(false);\n\n        Ok(widget_flags)\n    }\n\n    /// Reload the engine from the file that is set as origin file.\n    ///\n    /// If the origin file is set to None, this does nothing and returns an error.\n    pub(crate) async fn reload_from_disk(&self) -> anyhow::Result<()> {\n        let Some(output_file) = self.output_file() else {\n            return Err(anyhow::anyhow!(\n                \"Failed to reload file from disk, no file path saved.\"\n            ));\n        };\n        let (bytes, _) = output_file.load_bytes_future().await?;\n        let widget_flags = self\n            .load_in_rnote_bytes(bytes.to_vec(), output_file.path())\n            .await?;\n        self.emit_handle_widget_flags(widget_flags);\n        Ok(())\n    }\n\n    pub(crate) async fn load_in_xopp_bytes(\n        &self,\n        appwindow: &RnAppWindow,\n        bytes: Vec<u8>,\n    ) -> anyhow::Result<()> {\n        let xopp_import_prefs = appwindow\n            .engine_config()","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-ui/src/canvas/imexport.rs#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Only enable the reload/revert action when the document has an output file (check output_file().is_some() and desensitize the action otherwise).","Treat None as a no-op: return Ok(()) with a log instead of an error when there is no origin file.","Save the document first (dialog_save_doc_as) to establish an output path before allowing reload."],"exampleFix":"// before\nlet Some(output_file) = self.output_file() else {\n    return Err(anyhow::anyhow!(\n        \"Failed to reload file from disk, no file path saved.\"\n    ));\n};\n// after\nlet Some(output_file) = self.output_file() else {\n    log::debug!(\"reload_from_disk: no origin file, nothing to reload\");\n    return Ok(());\n};","handlingStrategy":"validation","validationCode":"// rust\nif canvas.output_file().is_none() {\n    eprintln!(\"document has no origin file; save it first before reload\");\n}","typeGuard":"fn can_reload(canvas: &RnCanvas) -> bool { canvas.output_file().is_some() }","tryCatchPattern":"if let Err(e) = canvas.reload_from_disk().await {\n    if e.to_string().contains(\"no file path saved\") {\n        // offer save-as instead\n        dialogs::canvas::dialog_save_doc_as(&appwindow).await?;\n    } else { return Err(e); }\n}","preventionTips":["Bind the revert/reload action's enabled state to output_file().is_some()","Treat unsaved documents as non-reloadable in autosave/watcher code","After opening files from pathless sources, always set output_file explicitly","Prompt save-as on first edit of an untitled document"],"tags":["file-io","state","canvas"],"backgroundTag":"missing-required-config-field","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}