/// Atomically copies a checkpoint with the specified name located at src
/// path into the specified dst path.
Atomically copies a checkpoint with the specified name located at src
path into the specified dst path.
Atomically copies a checkpoint with the specified name located at src path into the specified dst path .
fn copy_checkpoint(&self, name: &str, src: &Path, dst: &Path) -> std::io::Result<()> {
        let scratch_name = format!("scratchpad_{}", name);
        let scratchpad = self.tmp().join(&scratch_name);
        self.ensure_dir_exists(&scratchpad)?;
        if dst.exists() {
            return Err(Error::new(io::ErrorKind::AlreadyExists, name));
        }
        let copy_atomically = || {
            copy_recursively_respecting_tombstones(
                &self.log,
                src,
                scratchpad.as_path(),
                FilePermissions::ReadOnly,
            )?;
            std::fs::rename(&scratchpad, &dst)?;
            sync_path(&dst)
        };
        match copy_atomically() {
            Ok(()) => Ok(()),
            Err(err) => {
                let _ = std::fs::remove_dir_all(&scratchpad);
                Err(err)
            }
        }
    }
fn copy_checkpoint ( & self , name : & str , src : & Path , dst : & Path ) -> std :: io :: Result < ( ) > { let scratch_name = format ! ( " " name ) ; let scratchpad = self . tmp ( ) . join ( & scratch_name ) ; self . ensure_dir_exists ( & scratchpad ) ? ; if dst . exists ( ) { return Err ( Error :: new ( io :: ErrorKind :: AlreadyExists , name ) ) ; } let copy_atomically = | | { copy_recursively_respecting_tombstones ( & self . log , src , scratchpad . as_path ( ) , FilePermissions :: ReadOnly , ) ? ; std :: fs :: rename ( & scratchpad , & dst ) ? ; sync_path ( & dst ) } ; match copy_atomically ( ) { Ok ( ( ) ) => Ok ( ( ) ) , Err ( err ) => { let _ = std :: fs :: remove_dir_all ( & scratchpad ) ; Err ( err ) } } }
Atomically copies a checkpoint with the specified name located at src
path into the specified dst path.
Atomically copies a checkpoint with the specified name located at src path into the specified dst path .
&self
name
&str
src
&Path
dst
&Path