Do short exclusions for remote backups (also bump version as protocol version incompatible)

This commit is contained in:
Olivier 'reivilibre' 2022-07-08 15:31:12 +01:00
parent 080875bfce
commit 8612804298
6 changed files with 16 additions and 8 deletions

4
Cargo.lock generated
View File

@ -404,7 +404,7 @@ dependencies = [
[[package]] [[package]]
name = "datman" name = "datman"
version = "0.6.0-alpha.4" version = "0.6.0-alpha.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"arc-interner", "arc-interner",
@ -1733,7 +1733,7 @@ dependencies = [
[[package]] [[package]]
name = "yama" name = "yama"
version = "0.6.0-alpha.4" version = "0.6.0-alpha.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"blake", "blake",

View File

@ -1,6 +1,6 @@
[package] [package]
name = "datman" name = "datman"
version = "0.6.0-alpha.4" version = "0.6.0-alpha.5"
authors = ["Olivier 'reivilibre' <olivier@librepush.net>"] authors = ["Olivier 'reivilibre' <olivier@librepush.net>"]
edition = "2021" edition = "2021"
repository = "https://bics.ga/reivilibre/yama" repository = "https://bics.ga/reivilibre/yama"
@ -30,7 +30,7 @@ humansize = "1.1.1"
chrono = "0.4.19" chrono = "0.4.19"
itertools = "0.10.1" itertools = "0.10.1"
hostname = "0.3.1" hostname = "0.3.1"
yama = { path = "../yama", version = "0.6.0-alpha.1" } yama = { path = "../yama", version = "0.6.0-alpha.5" }
metrics = "0.17.1" metrics = "0.17.1"
bare-metrics-recorder = { version = "0.1.0" } bare-metrics-recorder = { version = "0.1.0" }
comfy-table = "6.0.0-rc.1" comfy-table = "6.0.0-rc.1"

View File

@ -213,6 +213,7 @@ pub fn interactive_labelling_session(path: &Path, source_name: String) -> anyhow
&mut write, &mut write,
directory.as_ref(), directory.as_ref(),
!*cross_filesystems, !*cross_filesystems,
&BTreeSet::new(),
)? )?
.ok_or_else(|| anyhow!("Remote scan failed (does the directory exist?)"))? .ok_or_else(|| anyhow!("Remote scan failed (does the directory exist?)"))?
.replace_meta(&None); .replace_meta(&None);

View File

@ -5,8 +5,9 @@ use crate::tree::FileTree;
use anyhow::{anyhow, bail}; use anyhow::{anyhow, bail};
use chrono::Utc; use chrono::Utc;
use log::info; use log::info;
use std::collections::BTreeSet;
use std::io::{Read, Write}; use std::io::{Read, Write};
use std::path::Path; use std::path::{Path, PathBuf};
use std::process::{Child, Command, Stdio}; use std::process::{Child, Command, Stdio};
use std::sync::Arc; use std::sync::Arc;
use yama::commands::{load_pile_descriptor, open_pile}; use yama::commands::{load_pile_descriptor, open_pile};
@ -49,11 +50,13 @@ pub fn scanning<R: Read, W: Write>(
write: &mut W, write: &mut W,
path: &Path, path: &Path,
one_filesystem: bool, one_filesystem: bool,
exclusions: &BTreeSet<PathBuf>,
) -> anyhow::Result<Option<FileTree<(), (), (), ()>>> { ) -> anyhow::Result<Option<FileTree<(), (), (), ()>>> {
info!("Scanning."); info!("Scanning.");
write_message(write, &"scan")?; write_message(write, &"scan")?;
write_message(write, &path)?; write_message(write, &path)?;
write_message(write, &one_filesystem)?; write_message(write, &one_filesystem)?;
write_message(write, exclusions)?;
write.flush()?; write.flush()?;
let scan_result: Option<FileTree<(), (), (), ()>> = read_message(read)?; let scan_result: Option<FileTree<(), (), (), ()>> = read_message(read)?;
@ -200,6 +203,9 @@ pub fn backup_remote_source_to_destination<PT: ProgressTracker + Send + 'static>
info!("Connecting..."); info!("Connecting...");
introduction(&mut read, &mut write)?; introduction(&mut read, &mut write)?;
let rules = load_labelling_rules(desc_path, source_name)?;
let exclusions = rules.get_exclusions_set(directory);
// then request to scan // then request to scan
info!("Requesting scan... (this may take some time)"); info!("Requesting scan... (this may take some time)");
let scan_result = scanning( let scan_result = scanning(
@ -207,10 +213,10 @@ pub fn backup_remote_source_to_destination<PT: ProgressTracker + Send + 'static>
&mut write, &mut write,
directory.as_ref(), directory.as_ref(),
!*cross_filesystems, !*cross_filesystems,
&exclusions,
)? )?
.ok_or_else(|| anyhow!("Remote scan failed (does the directory exist?)"))?; .ok_or_else(|| anyhow!("Remote scan failed (does the directory exist?)"))?;
let rules = load_labelling_rules(desc_path, source_name)?;
let mut root = let mut root =
label_filter_and_convert(scan_result, descriptor, source_name, &rules, dest)? label_filter_and_convert(scan_result, descriptor, source_name, &rules, dest)?
.ok_or_else(|| anyhow!("Empty filter..."))?; .ok_or_else(|| anyhow!("Empty filter..."))?;

View File

@ -44,7 +44,8 @@ pub fn introduction<R: Read, W: Write>(read: &mut R, write: &mut W) -> anyhow::R
pub fn scanning<R: Read, W: Write>(read: &mut R, write: &mut W) -> anyhow::Result<()> { pub fn scanning<R: Read, W: Write>(read: &mut R, write: &mut W) -> anyhow::Result<()> {
let path: PathBuf = read_message(read)?; let path: PathBuf = read_message(read)?;
let one_filesystem: bool = read_message(read)?; let one_filesystem: bool = read_message(read)?;
let scan_result = scan(&path, one_filesystem, &BTreeSet::new())?; let exclusions: BTreeSet<PathBuf> = read_message(read)?;
let scan_result = scan(&path, one_filesystem, &exclusions)?;
write_message(write, &scan_result)?; write_message(write, &scan_result)?;
write.flush()?; write.flush()?;
Ok(()) Ok(())

View File

@ -1,6 +1,6 @@
[package] [package]
name = "yama" name = "yama"
version = "0.6.0-alpha.4" version = "0.6.0-alpha.5"
authors = ["Olivier 'reivilibre' <olivier@librepush.net>"] authors = ["Olivier 'reivilibre' <olivier@librepush.net>"]
edition = "2018" edition = "2018"
description = "Deduplicated, compressed and encrypted content pile manager" description = "Deduplicated, compressed and encrypted content pile manager"