|
1 | 1 | #![deny(unused_must_use)] |
2 | 2 |
|
3 | 3 | mod backend; |
4 | | -use std::{ffi::{OsStr, OsString}, io::{ErrorKind, Write}, path::{Path, PathBuf}, sync::Arc}; |
| 4 | +use std::{ffi::{OsStr, OsString}, io::{Error, ErrorKind, Write}, path::{Path, PathBuf}, sync::Arc}; |
5 | 5 |
|
6 | 6 | pub use backend::*; |
7 | 7 | use bridge::instance::InstanceContentSummary; |
@@ -228,7 +228,7 @@ pub fn copy_content_recursive(from: &Path, to: &Path) -> std::io::Result<()> { |
228 | 228 | let path = entry.path(); |
229 | 229 | let file_type = entry.file_type()?; |
230 | 230 | let Ok(relative) = path.strip_prefix(&from) else { |
231 | | - return Err(ErrorKind::Other.into()); |
| 231 | + return Err(Error::new(ErrorKind::Other, format!("{path:?} is not a child of {from:?}"))); |
232 | 232 | }; |
233 | 233 | if file_type.is_symlink() { |
234 | 234 | let target = std::fs::read_link(&path)?; |
@@ -272,7 +272,8 @@ pub fn copy_content_recursive(from: &Path, to: &Path) -> std::io::Result<()> { |
272 | 272 | copied_bytes += std::fs::copy(copy_from, dest)?; |
273 | 273 | } |
274 | 274 | if copied_bytes != total_bytes { |
275 | | - return Err(ErrorKind::Interrupted.into()); |
| 275 | + return Err(Error::new(ErrorKind::Other, |
| 276 | + format!("Expected copy size did not match. Expected to copy {total_bytes} bytes, copied {copied_bytes} instead"))); |
276 | 277 | } |
277 | 278 | for (relative, internal) in internal_symlinks { |
278 | 279 | let dest = to.join(relative); |
@@ -345,7 +346,7 @@ pub fn rename_with_fallback_across_devices(from: &Path, to: &Path) -> std::io::R |
345 | 346 | std::fs::copy(from, to)?; |
346 | 347 | _ = std::fs::remove_file(from); |
347 | 348 | } else { |
348 | | - return Err(ErrorKind::InvalidInput.into()); |
| 349 | + return Err(Error::new(ErrorKind::Other, format!("{from} is not a symlink, file or folder"))); |
349 | 350 | } |
350 | 351 | return Ok(()); |
351 | 352 | } |
|
0 commit comments