sync: Save snapshot to a file before receive

This commit is contained in:
2021-10-19 17:56:46 +02:00
parent 0e583377e9
commit 905452e91b
4 changed files with 152 additions and 36 deletions

View File

@ -1,3 +1,4 @@
use std::path::Path;
use std::time::Duration;
pub fn format_duration(d: Duration) -> String {
@ -12,3 +13,8 @@ pub fn format_duration(d: Duration) -> String {
(_, _) => format!("{}h {}m {:.2}s", hours, minutes, seconds),
}
}
pub fn path_as_utf8(path: &Path) -> anyhow::Result<&str> {
path.to_str()
.ok_or_else(|| anyhow::format_err!("path not utf-8"))
}