/// Traverse the source file tree and constructs a copy-plan:
/// a collection of I/O operations that need to be performed to copy the source
/// to the destination while ignoring directories that have tombstones.
Traverse the source file tree and constructs a copy-plan:
a collection of I/O operations that need to be performed to copy the source
to the destination while ignoring directories that have tombstones.
Traverse the source file tree and constructs a copy - plan : a collection of I / O operations that need to be performed to copy the source to the destination while ignoring directories that have tombstones .
fn build_copy_plan(src: &Path, dst: &Path, plan: &mut CopyPlan) -> std::io::Result<()> {
    let src_metadata = src.metadata()?;
    if src_metadata.is_dir() {
        if src.join("tombstone").exists() {
            // The source directory was marked as removed by placing a
            // 'tombstone' file inside. We don't want this directory in
            // a checkpoint.
            return Ok(());
        }
        // First create the target directory.
        plan.create_and_sync_dir.push(CreateAndSyncDir {
            dst: PathBuf::from(dst),
        });
        // Then copy and sync all children.
        let entries = src.read_dir()?;
        for entry_result in entries {
            let entry = entry_result?;
            let dst_entry = dst.join(entry.file_name());
            build_copy_plan(&entry.path(), &dst_entry, plan)?;
        }
    } else {
        plan.copy_and_sync_file.push(CopyAndSyncFile {
            src: PathBuf::from(src),
            dst: PathBuf::from(dst),
        });
    }
    Ok(())
}
fn build_copy_plan ( src : & Path , dst : & Path , plan : & mut CopyPlan ) -> std :: io :: Result < ( ) > { let src_metadata = src . metadata ( ) ? ; if src_metadata . is_dir ( ) { if src . join ( " " ) . exists ( ) { // The source directory was marked as removed by placing a // 'tombstone' file inside. We don't want this directory in // a checkpoint. return Ok ( ( ) ) ; } // First create the target directory. plan . create_and_sync_dir . push ( CreateAndSyncDir { dst : PathBuf :: from ( dst ) , } ) ; // Then copy and sync all children. let entries = src . read_dir ( ) ? ; for entry_result in entries { let entry = entry_result ? ; let dst_entry = dst . join ( entry . file_name ( ) ) ; build_copy_plan ( & entry . path ( ) , & dst_entry , plan ) ? ; } } else { plan . copy_and_sync_file . push ( CopyAndSyncFile { src : PathBuf :: from ( src ) , dst : PathBuf :: from ( dst ) , } ) ; } Ok ( ( ) ) }
Traverse the source file tree and constructs a copy-plan:
a collection of I/O operations that need to be performed to copy the source
to the destination while ignoring directories that have tombstones.
Traverse the source file tree and constructs a copy - plan : a collection of I / O operations that need to be performed to copy the source to the destination while ignoring directories that have tombstones .
src
&Path
dst
&Path
plan
&mut CopyPlan