refactorize the dump and snapshot

This commit is contained in:
Tamo 2021-10-26 13:02:40 +02:00 committed by marin postma
parent 87a8bf5e96
commit c752c14c46
No known key found for this signature in database
GPG key ID: 6088B7721C3E39F9
6 changed files with 28 additions and 24 deletions

View file

@ -1,17 +1,8 @@
use std::{fs, path::Path};
/// To load a dump we get the user id from the source directory;
/// If there was a user-id, write it to the new destination if not ignore the error
pub fn load_dump(src: &Path, dst: &Path) {
/// Copy the `user-id` contained in one db to another. Ignore all errors.
pub fn copy_user_id(src: &Path, dst: &Path) {
if let Ok(user_id) = fs::read_to_string(src.join("user-id")) {
let _ = fs::write(dst.join("user-id"), &user_id);
}
}
/// To load a dump we get the user id either from the source directory;
/// If there was a user-id, write it to the new destination if not ignore the error
pub fn write_dump(src: &Path, dst: &Path) {
if let Ok(user_id) = fs::read_to_string(src) {
let _ = fs::write(dst, &user_id);
}
}