More atomic "file moves+transaction"

[?]
Mar 9, 2021, 9:05 PM
EEOOHGQQK43J36LQJDSS3UK56M54DXPYE4VB3K4A2XAYGOYDJAXAC

Dependencies

  • [2] PP3E3TRE Do not move source if destination is wrong
  • [3] L4JXJHWX pijul/*: reorganize imports and remove extern crate
  • [4] SXEYMYF7 Fixing the bad changes in history (unfortunately, by rebooting).
  • [5] Y7YAFMFF Fix path prefix striping on Windows.

Change contents

  • replacement in pijul/src/commands/file_operations.rs at line 2
    [3.169184][3.169184:169208]()
    use std::path::PathBuf;
    [3.169184]
    [3.2404]
    use std::path::{Path, PathBuf};
  • replacement in pijul/src/commands/file_operations.rs at line 49
    [3.170280][2.0:58]()
    let target = std::fs::canonicalize(&target)?;
    [3.170280]
    [2.58]
    let r = Rename {
    source: &source,
    target: &target,
    };
    std::fs::rename(r.source, r.target)?;
    let target = std::fs::canonicalize(r.target)?;
  • replacement in pijul/src/commands/file_operations.rs at line 61
    [2.361][2.361:409]()
    std::fs::rename(&source, &target)?;
    [2.361]
    [3.170538]
    std::mem::forget(r);
  • edit in pijul/src/commands/file_operations.rs at line 66
    [3.170592]
    [3.170592]
    }
    struct Rename<'a> {
    source: &'a Path,
    target: &'a Path,
  • edit in pijul/src/commands/file_operations.rs at line 73
    [3.170595]
    [3.170595]
    impl<'a> Drop for Rename<'a> {
    fn drop(&mut self) {
    std::fs::rename(self.target, self.source).unwrap_or(())
    }
    }