pub(crate) fn copy_files(
        log: &ReplicaLogger,
        root_old: &Path,
        root_new: &Path,
        manifest_old: &Manifest,
        manifest_new: &Manifest,
        diff_script: &DiffScript,
    ) {
        for (new_index, old_index) in diff_script.copy_files.iter() {
            let src_path = root_old.join(&manifest_old.file_table[*old_index].relative_path);
            let dst_path = root_new.join(&manifest_new.file_table[*new_index].relative_path);

            if dst_path.ends_with("state_file") {
                // It is guaranteed by the different domain hash separators.
                assert!(src_path.ends_with("state_file"));

                let src_cow_base_dir = src_path.parent().expect("paths must have a parent");
                let dst_cow_base_dir = dst_path.parent().expect("paths must have a parent");

                let src_cow_mgr =
                    CowMemoryManagerImpl::open_readonly(src_cow_base_dir.to_path_buf());
                let src_mapped_state = src_cow_mgr.get_map();
                src_mapped_state.make_heap_accessible();
                let src_heap_base = src_mapped_state.get_heap_base();
                let size_bytes = manifest_old.file_table[*old_index].size_bytes as usize;
                let data: &[u8] = unsafe { std::slice::from_raw_parts(src_heap_base, size_bytes) };
                assert_eq!(data.len() % *PAGE_SIZE, 0);

                let dst_cow_mgr =
                    CowMemoryManagerImpl::open_readwrite_statesync(dst_cow_base_dir.to_path_buf());
                let dst_mapped_state = dst_cow_mgr.get_map();

                let nr_pages = data.len() / *PAGE_SIZE;
                let pages_to_copy: Vec<u64> = (0..nr_pages).map(|page| page as u64).collect();
                dst_mapped_state.copy_to_heap(0, &data);
                dst_mapped_state.soft_commit(&pages_to_copy);
            } else {
                assert!(!src_path.ends_with("state_file"));
                do_copy_overwrite(log, &src_path, &dst_path).unwrap_or_else(|err| {
                    fatal!(
                        log,
                        "Failed to copy file from {} to {}: {}",
                        src_path.display(),
                        dst_path.display(),
                        err
                    )
                });
            }
        }
    }
/// Copy reusable files from previous checkpoint according to diff script.
Copy reusable files from previous checkpoint according to diff script.
Copy reusable files from previous checkpoint according to diff script .
pub(crate) fn copy_files(
        log: &ReplicaLogger,
        root_old: &Path,
        root_new: &Path,
        manifest_old: &Manifest,
        manifest_new: &Manifest,
        diff_script: &DiffScript,
    ) {
        for (new_index, old_index) in diff_script.copy_files.iter() {
            let src_path = root_old.join(&manifest_old.file_table[*old_index].relative_path);
            let dst_path = root_new.join(&manifest_new.file_table[*new_index].relative_path);
            if dst_path.ends_with("state_file") {
                // It is guaranteed by the different domain hash separators.
                assert!(src_path.ends_with("state_file"));
                let src_cow_base_dir = src_path.parent().expect("paths must have a parent");
                let dst_cow_base_dir = dst_path.parent().expect("paths must have a parent");
                let src_cow_mgr =
                    CowMemoryManagerImpl::open_readonly(src_cow_base_dir.to_path_buf());
                let src_mapped_state = src_cow_mgr.get_map();
                src_mapped_state.make_heap_accessible();
                let src_heap_base = src_mapped_state.get_heap_base();
                let size_bytes = manifest_old.file_table[*old_index].size_bytes as usize;
                let data: &[u8] = unsafe { std::slice::from_raw_parts(src_heap_base, size_bytes) };
                assert_eq!(data.len() % *PAGE_SIZE, 0);
                let dst_cow_mgr =
                    CowMemoryManagerImpl::open_readwrite_statesync(dst_cow_base_dir.to_path_buf());
                let dst_mapped_state = dst_cow_mgr.get_map();
                let nr_pages = data.len() / *PAGE_SIZE;
                let pages_to_copy: Vec<u64> = (0..nr_pages).map(|page| page as u64).collect();
                dst_mapped_state.copy_to_heap(0, &data);
                dst_mapped_state.soft_commit(&pages_to_copy);
            } else {
                assert!(!src_path.ends_with("state_file"));
                do_copy_overwrite(log, &src_path, &dst_path).unwrap_or_else(|err| {
                    fatal!(
                        log,
                        "Failed to copy file from {} to {}: {}",
                        src_path.display(),
                        dst_path.display(),
                        err
                    )
                });
            }
        }
    }
pub ( crate ) fn copy_files ( log : & ReplicaLogger , root_old : & Path , root_new : & Path , manifest_old : & Manifest , manifest_new : & Manifest , diff_script : & DiffScript , ) { for ( new_index , old_index ) in diff_script . copy_files . iter ( ) { let src_path = root_old . join ( & manifest_old . file_table [ * old_index ] . relative_path ) ; let dst_path = root_new . join ( & manifest_new . file_table [ * new_index ] . relative_path ) ; if dst_path . ends_with ( " " ) { // It is guaranteed by the different domain hash separators. assert ! ( src_path ends_with ( " " ) ) ; let src_cow_base_dir = src_path . parent ( ) . expect ( " " ) ; let dst_cow_base_dir = dst_path . parent ( ) . expect ( " " ) ; let src_cow_mgr = CowMemoryManagerImpl :: open_readonly ( src_cow_base_dir . to_path_buf ( ) ) ; let src_mapped_state = src_cow_mgr . get_map ( ) ; src_mapped_state . make_heap_accessible ( ) ; let src_heap_base = src_mapped_state . get_heap_base ( ) ; let size_bytes = manifest_old . file_table [ * old_index ] . size_bytes as usize ; let data : & [ u8 ] = unsafe { std :: slice :: from_raw_parts ( src_heap_base , size_bytes ) } ; assert_eq ! ( data len ( ) PAGE_SIZE 0 ) ; let dst_cow_mgr = CowMemoryManagerImpl :: open_readwrite_statesync ( dst_cow_base_dir . to_path_buf ( ) ) ; let dst_mapped_state = dst_cow_mgr . get_map ( ) ; let nr_pages = data . len ( ) / * PAGE_SIZE ; let pages_to_copy : Vec < u64 > = ( 0 .. nr_pages ) . map ( | page | page as u64 ) . collect ( ) ; dst_mapped_state . copy_to_heap ( 0 , & data ) ; dst_mapped_state . soft_commit ( & pages_to_copy ) ; } else { assert ! ( src_path ends_with ( " " ) ) ; do_copy_overwrite ( log , & src_path , & dst_path ) . unwrap_or_else ( | err | { fatal ! ( log " " src_path display ( ) dst_path display ( ) err ) } ) ; } } }
Copy reusable files from previous checkpoint according to diff script.
Copy reusable files from previous checkpoint according to diff script .
log
&ReplicaLogger
root_old
&Path
root_new
&Path
manifest_old
&Manifest
manifest_new
&Manifest
diff_script
&DiffScript
log
&ReplicaLogger
root_old
&Path
root_new
&Path
manifest_old
&Manifest
manifest_new
&Manifest
diff_script
&DiffScript