0
0
mirror of https://github.com/TeFiLeDo/listload.git synced 2024-11-01 10:06:16 +01:00

use hard-linking or copying instead of renaming

This commit is contained in:
Adrian Wannenmacher 2023-06-27 23:30:19 +02:00
parent 55c60fbb84
commit 72820bf48a
Signed by: tfld
GPG Key ID: 19D986ECB1E492D5

View File

@ -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 {