/// Atomically removes path by first renaming it into tmp_path, and then
/// deleting tmp_path.
Atomically removes path by first renaming it into tmp_path, and then
deleting tmp_path.
Atomically removes path by first renaming it into tmp_path and then deleting tmp_path .
fn atomically_remove_via_path(&self, path: &Path, tmp_path: &Path) -> std::io::Result<()> {
        // We first move the checkpoint directory into a temporary directory to
        // maintain the invariant that <root>/checkpoints/<height> are always
        // internally consistent.
        match std::fs::rename(path, tmp_path) {
            Ok(_) => {
                if let Some(parent) = path.parent() {
                    sync_path(parent)?;
                }
            }
            Err(err) if err.kind() == std::io::ErrorKind::NotFound => {
                return Ok(());
            }
            Err(err) => return Err(err),
        }
        std::fs::remove_dir_all(tmp_path)
    }
fn atomically_remove_via_path ( & self , path : & Path , tmp_path : & Path ) -> std :: io :: Result < ( ) > { // We first move the checkpoint directory into a temporary directory to // maintain the invariant that <root>/checkpoints/<height> are always // internally consistent. match std :: fs :: rename ( path , tmp_path ) { Ok ( _ ) => { if let Some ( parent ) = path . parent ( ) { sync_path ( parent ) ? ; } } Err ( err ) if err . kind ( ) == std :: io :: ErrorKind :: NotFound => { return Ok ( ( ) ) ; } Err ( err ) => return Err ( err ) , } std :: fs :: remove_dir_all ( tmp_path ) }
Atomically removes path by first renaming it into tmp_path, and then
deleting tmp_path.
Atomically removes path by first renaming it into tmp_path and then deleting tmp_path .
&self
path
&Path
tmp_path
&Path