Skip to content

Commit cd1f614

Browse files
committed
Treat EXDEV as unsupported clonefile and handle possum_new error from Go
1 parent 35d7f9c commit cd1f614

File tree

5 files changed

+15
-5
lines changed

5 files changed

+15
-5
lines changed

go/handle.go

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ type Limits = possumC.Limits
1919

2020
func Open(dir string) (handle *Handle, err error) {
2121
cHandle := possumC.NewHandle(dir)
22+
if cHandle == nil {
23+
err = errors.New("unhandled possum error")
24+
return
25+
}
2226
generics.InitNew(&handle)
2327
handle.cHandle.Init(cHandle, func(cHandle *possumC.Handle) {
2428
possumC.DropHandle(cHandle)

src/c_api/ext_fns/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub extern "C" fn possum_new(path: *const c_char) -> *mut PossumHandle {
2929
let handle = match Handle::new(path_buf.clone()) {
3030
Ok(handle) => handle,
3131
Err(err) => {
32-
error!("error creating possum handle in {path_buf:?}: {err}");
32+
error!("error creating possum handle in {path_buf:?}: {err:#?}");
3333
return null_mut();
3434
}
3535
};

src/dir.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,14 @@ impl Dir {
3737
let _ = std::fs::remove_file(&dst_path);
3838
match clone_res {
3939
Ok(()) => true,
40-
Err(err) if CloneFileError::is_unsupported(&err) => false,
41-
Err(err) => return Err(err).context("testing clonefile"),
40+
Err(err) if CloneFileError::is_unsupported(&err) => {
41+
warn!(?err, "clonefile unsupported");
42+
false
43+
},
44+
Err(err) => {
45+
error!(?err);
46+
return Err(err).context("testing clonefile")
47+
},
4248
}
4349
}
4450
};

src/handle.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl Handle {
103103
"3.42"
104104
);
105105
}
106-
let dir = Dir::new(dir)?;
106+
let dir = Dir::new(dir).context("new Dir")?;
107107
let mut conn = Connection::open(dir.path().join(MANIFEST_DB_FILE_NAME))?;
108108
Self::init_sqlite_conn(&mut conn, &dir)?;
109109
let (deleted_values, receiver) = sync::mpsc::sync_channel(10);

src/sys/clonefile/sys.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ impl CloneFileError for NativeIoError {
2727
#[cfg(unix)]
2828
fn is_unsupported(&self) -> bool {
2929
self.raw_os_error()
30-
.map(|errno| matches!(errno, EOPNOTSUPP))
30+
.map(|errno| matches!(errno, EOPNOTSUPP | libc::EXDEV))
3131
.unwrap_or_default()
3232
}
3333
#[cfg(windows)]

0 commit comments

Comments
 (0)