Skip to content

Commit

Permalink
handle readonly
Browse files Browse the repository at this point in the history
  • Loading branch information
kirawi committed Jan 5, 2024
1 parent 86eb32a commit ea7899d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,12 @@ impl Document {
}
}

// TODO: Fail if path is read-only.
match rustix::fs::access(&path, rustix::fs::Access::WRITE_OK) {
Ok(_) => {}
Err(err) if err.kind() == std::io::ErrorKind::NotFound => {}
Err(_) => bail!("file is readonly"),
};

let (mut tmp_file, tmp_path) = tokio::task::spawn_blocking(
move || -> anyhow::Result<(File, tempfile::TempPath)> {
let (f, p) = tempfile::NamedTempFile::new()?.into_parts();
Expand Down

0 comments on commit ea7899d

Please sign in to comment.