Skip to content

Migrations to 1.x.x version

Denis Kurilenko edited this page Mar 8, 2017 · 1 revision

What's changed

Now all with_process functions not right immediate shutdown with error. Now if happen error we get opportunity decide what do to do in next.

Affordable solutions:

  • Overwrite - Access only if error type of exist. Overwrite only current file.
  • OverwriteAll - Access only if error type of exist. Overwrite for all files with same error type.
  • Skip - Skip only current file.
  • SkipAll - Skip all files with same error type.
  • Retry - Try again current operation.
  • Abort - Abort current operation.

Real case from life

Sometimes you wanna copy some files from one place to another. But some file can already exist to destination path, and some files we want overwrite, some files doesn't. Now you can check files on rules when error occur. This case very frequently happen in file managers system like Total Commander, Midnight Commander and etc.

From 0.x.x to 1.x.x

You should add return value for your all closures except files.

Before

extern crate fs_extra;
use fs_extra::file::copy_with_progress;

let options = CopyOptions::new(); 
let handle = |process_info: TransitProcess|  println!("{}", process_info.total_bytes);

copy_with_progress("dir1/foo.txt", "dir2/foo.txt", &options, handle)?;

After

extern crate fs_extra;
use fs_extra::file::copy_with_progress;

let options = CopyOptions::new(); 
let handle = |process_info: TransitProcess|  {
   println!("{}", process_info.total_bytes);
   fs_extra::dir::TransitProcessResult::ContinueOrAbort // Return value
}

copy_with_progress("dir1/foo.txt", "dir2/foo.txt", &options, handle)?;
Clone this wiki locally