Skip to content

Commit f722e7b

Browse files
committed
fix(ffi): Handle PermissionDenied error in copy_with_cp fallback on Windows
The copy_with_cp function in build.rs attempts to use `cp -R` which fails on Windows, then falls back to `std::fs::copy()`. However, `fs::copy()` cannot copy directories and throws PermissionDenied on Windows instead of InvalidInput. This commit extends the error handling to catch both InvalidInput and PermissionDenied error kinds, routing both to copy_dir_all which properly handles directory copying across all platforms. Fixes: Windows builds panicking with PermissionDenied (OS Error 5)
1 parent e4beaca commit f722e7b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

libsql-ffi/build.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,12 @@ fn copy_with_cp(from: impl AsRef<Path>, to: impl AsRef<Path>) -> io::Result<()>
8989
{
9090
Ok(status) if status.success() => Ok(()),
9191
_ => match fs::copy(from.as_ref(), to.as_ref()) {
92-
Err(err) if err.kind() == io::ErrorKind::InvalidInput => copy_dir_all(from, to),
92+
Err(err)
93+
if err.kind() == io::ErrorKind::InvalidInput
94+
|| err.kind() == io::ErrorKind::PermissionDenied =>
95+
{
96+
copy_dir_all(from, to),
97+
}
9398
Ok(_) => Ok(()),
9499
Err(err) => Err(err),
95100
},

0 commit comments

Comments
 (0)