Skip to content

Commit

Permalink
Treat EXDEV as unsupported clonefile and handle possum_new error from Go
Browse files Browse the repository at this point in the history
  • Loading branch information
anacrolix committed Oct 9, 2024
1 parent 35d7f9c commit cd1f614
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 4 additions & 0 deletions go/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ type Limits = possumC.Limits

func Open(dir string) (handle *Handle, err error) {
cHandle := possumC.NewHandle(dir)
if cHandle == nil {
err = errors.New("unhandled possum error")
return
}
generics.InitNew(&handle)
handle.cHandle.Init(cHandle, func(cHandle *possumC.Handle) {
possumC.DropHandle(cHandle)
Expand Down
2 changes: 1 addition & 1 deletion src/c_api/ext_fns/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub extern "C" fn possum_new(path: *const c_char) -> *mut PossumHandle {
let handle = match Handle::new(path_buf.clone()) {
Ok(handle) => handle,
Err(err) => {
error!("error creating possum handle in {path_buf:?}: {err}");
error!("error creating possum handle in {path_buf:?}: {err:#?}");
return null_mut();
}
};
Expand Down
10 changes: 8 additions & 2 deletions src/dir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ impl Dir {
let _ = std::fs::remove_file(&dst_path);
match clone_res {
Ok(()) => true,
Err(err) if CloneFileError::is_unsupported(&err) => false,
Err(err) => return Err(err).context("testing clonefile"),
Err(err) if CloneFileError::is_unsupported(&err) => {
warn!(?err, "clonefile unsupported");
false
},
Err(err) => {
error!(?err);
return Err(err).context("testing clonefile")
},
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl Handle {
"3.42"
);
}
let dir = Dir::new(dir)?;
let dir = Dir::new(dir).context("new Dir")?;
let mut conn = Connection::open(dir.path().join(MANIFEST_DB_FILE_NAME))?;
Self::init_sqlite_conn(&mut conn, &dir)?;
let (deleted_values, receiver) = sync::mpsc::sync_channel(10);
Expand Down
2 changes: 1 addition & 1 deletion src/sys/clonefile/sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl CloneFileError for NativeIoError {
#[cfg(unix)]
fn is_unsupported(&self) -> bool {
self.raw_os_error()
.map(|errno| matches!(errno, EOPNOTSUPP))
.map(|errno| matches!(errno, EOPNOTSUPP | libc::EXDEV))
.unwrap_or_default()
}
#[cfg(windows)]
Expand Down

0 comments on commit cd1f614

Please sign in to comment.