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 92a5907
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions helix-view/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,12 @@ impl Document {
}
}

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"),
};

// TODO: Fail if path is read-only.
let (mut tmp_file, tmp_path) = tokio::task::spawn_blocking(
move || -> anyhow::Result<(File, tempfile::TempPath)> {
Expand Down

0 comments on commit 92a5907

Please sign in to comment.