flxzt/rnote · error · anyhow::Error
Supplied target file
Error message
Supplied target file `{dir:?}` is not a directory. What it means
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.
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).
Example fix
// before
export_doc_pages(dir, file_stem_name, None, &appwindow).await?;
// after
if dir.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE) != gio::FileType::Directory {
anyhow::bail!("Export target is not a directory: {:?}", dir.uri());
}
export_doc_pages(dir, file_stem_name, None, &appwindow).await?; Defensive patterns
Strategy: validation
Validate before calling
if dir.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE) != gio::FileType::Directory {
bail!("{} is not a directory", dir.uri());
} Type guard
fn is_directory(f: &gio::File) -> bool {
f.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE) == gio::FileType::Directory
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not retrieve basename for file
- The output file " " needs to have a supported extension to…
- Exporting document to format with extension
- DocExportFormat try_from
- DocPagesExportFormat try_from
AI-assisted analysis of flxzt/rnote@bbc5354502 (2026-09-08).
Data as JSON: /api/errors/9761648d494da79a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/rnote-ui/src/canvas/imexport.rs:306
self.set_last_export_dir(file.parent());
Ok(())
}
/// Exports document pages
/// `file_stem_name`: the stem name of the created files. This is extended by an enumeration of the page number and
/// file extension overwrites existing files with the same name!
pub(crate) async fn export_doc_pages(
&self,
appwindow: &RnAppWindow,
dir: &gio::File,
file_stem_name: String,
export_prefs_override: Option<DocPagesExportPrefs>,
) -> anyhow::Result<()> {
if dir.query_file_type(gio::FileQueryInfoFlags::NONE, gio::Cancellable::NONE)
!= gio::FileType::Directory
{
return Err(anyhow::anyhow!(
"Supplied target file `{dir:?}` is not a directory."
));
}
let export_prefs = export_prefs_override.unwrap_or(
appwindow
.engine_config()
.read()
.export_prefs
.doc_pages_export_prefs,
);
let file_ext = export_prefs.export_format.file_ext();
let export_bytes_recv = self.engine_ref().export_doc_pages(export_prefs_override);
let export_bytes = export_bytes_recv.await??;
for (i, page_bytes) in export_bytes.into_iter().enumerate() {
crate::utils::create_replace_file_future(
page_bytes,View on GitHub (pinned to bbc5354502)