{"record":{"id":"9761648d494da79a","repo":"flxzt/rnote","slug":"supplied-target-file-dir-is-not-a-directory","errorCode":null,"errorMessage":"Supplied target file `{dir:?}` is not a directory.","messagePattern":"Supplied target file `(.+?)` is not a directory\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/rnote-ui/src/canvas/imexport.rs","lineNumber":306,"sourceCode":"        self.set_last_export_dir(file.parent());\n\n        Ok(())\n    }\n\n    /// Exports document pages\n    /// `file_stem_name`: the stem name of the created files. This is extended by an enumeration of the page number and\n    /// file extension overwrites existing files with the same name!\n    pub(crate) async fn export_doc_pages(\n        &self,\n        appwindow: &RnAppWindow,\n        dir: &gio::File,\n        file_stem_name: String,\n        export_prefs_override: Option<DocPagesExportPrefs>,\n    ) -> anyhow::Result<()> {\n        if dir.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE)\n            != gio::FileType::Directory\n        {\n            return Err(anyhow::anyhow!(\n                \"Supplied target file `{dir:?}` is not a directory.\"\n            ));\n        }\n        let export_prefs = export_prefs_override.unwrap_or(\n            appwindow\n                .engine_config()\n                .read()\n                .export_prefs\n                .doc_pages_export_prefs,\n        );\n        let file_ext = export_prefs.export_format.file_ext();\n\n        let export_bytes_recv = self.engine_ref().export_doc_pages(export_prefs_override);\n        let export_bytes = export_bytes_recv.await??;\n\n        for (i, page_bytes) in export_bytes.into_iter().enumerate() {\n            crate::utils::create_replace_file_future(\n                page_bytes,","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/flxzt/rnote/blob/bbc5354502ba2fc83eec2670b535348825e679a6/crates/rnote-ui/src/canvas/imexport.rs#L288-L324","documentation":"Thrown in `export_doc_pages` when the supplied `gio::File` for the export target passes a file-type query and is not of `gio::FileType::Directory`. Page export requires a directory to write numbered page files into; any non-directory target (regular file, symlink to file, missing entry) is rejected up front.","triggerScenarios":"Calling `export_doc_pages` with a `dir` GFile that points to a regular file or a non-existent path, e.g. the user picked a file instead of a folder in the export dialog, or the target folder was deleted/moved between selection and export.","commonSituations":"Exporting document pages after the chosen output folder was removed; a stale bookmark pointing to a file; passing a file path programmatically via CLI or scripting where a directory was expected.","solutions":["Check `dir.query_file_type(...) == gio::FileType::Directory` before calling `export_doc_pages`.","Re-select the export folder in the dialog, making sure a directory is chosen.","If the folder may be missing, create it first with `gio::File::make_directory_with_parents()`.","Verify the path exists and is a real folder (check for symlinks resolving to files)."],"exampleFix":"// before\nexport_doc_pages(dir, file_stem_name, None, &appwindow).await?;\n// after\nif dir.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE) != gio::FileType::Directory {\n    anyhow::bail!(\"Export target is not a directory: {:?}\", dir.uri());\n}\nexport_doc_pages(dir, file_stem_name, None, &appwindow).await?;","handlingStrategy":"validation","validationCode":"if dir.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE) != gio::FileType::Directory {\n    bail!(\"{} is not a directory\", dir.uri());\n}","typeGuard":"fn is_directory(f: &gio::File) -> bool {\n    f.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE) == gio::FileType::Directory\n}","tryCatchPattern":null,"preventionTips":["Use folder-select mode in file choosers for page-export targets","Re-verify the directory still exists right before export","Create the target directory with make_directory_with_parents if missing"],"tags":["gio","file-io","directory","export"],"backgroundTag":"path-is-not-a-directory","analyzedSha":"bbc5354502ba2fc83eec2670b535348825e679a6","analyzedAt":"2026-09-08T13:20:33.747Z","contentChangedAt":"2026-09-08T13:20:33.747Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}