mirror of
https://github.com/TeFiLeDo/listload.git
synced 2024-11-23 20:56:17 +01:00
use hard-linking or copying instead of renaming
This commit is contained in:
parent
55c60fbb84
commit
72820bf48a
12
src/main.rs
12
src/main.rs
@ -96,7 +96,17 @@ fn main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
.and_then(|target| {
|
.and_then(|target| {
|
||||||
fs::rename(&res.file_name, target).context("failed to move cached result")
|
fs::hard_link(&res.file_name, &target)
|
||||||
|
.context("failed to hard-link result") // for same type as below
|
||||||
|
.or_else(|_| {
|
||||||
|
fs::copy(&res.file_name, &target)
|
||||||
|
.map(|_| ())
|
||||||
|
.context("failed to copy result")
|
||||||
|
})
|
||||||
|
.and_then(|_| {
|
||||||
|
fs::remove_file(&res.file_name)
|
||||||
|
.context("failed to delete cached result")
|
||||||
|
})
|
||||||
});
|
});
|
||||||
|
|
||||||
if let Err(err) = res {
|
if let Err(err) = res {
|
||||||
|
Loading…
Reference in New Issue
Block a user