mirror of
https://github.com/rustic-rs/rustic.git
synced 2025-10-26 11:18:51 +00:00
backup: Add option --ignore-devid
This commit is contained in:
parent
834e8c89a9
commit
1bd624ecb9
@ -19,6 +19,7 @@ pub struct LocalSource {
|
||||
builder: WalkBuilder,
|
||||
walker: Walk,
|
||||
with_atime: bool,
|
||||
ignore_devid: bool,
|
||||
cache: UsersCache,
|
||||
}
|
||||
|
||||
@ -31,6 +32,11 @@ pub struct LocalSourceOptions {
|
||||
#[merge(strategy = merge::bool::overwrite_false)]
|
||||
with_atime: bool,
|
||||
|
||||
/// Don't save device ID for files and directories
|
||||
#[clap(long)]
|
||||
#[merge(strategy = merge::bool::overwrite_false)]
|
||||
ignore_devid: bool,
|
||||
|
||||
/// Glob pattern to exclude/include (can be specified multiple times)
|
||||
#[clap(long, short = 'g', help_heading = "EXCLUDE OPTIONS")]
|
||||
#[merge(strategy = merge::vec::overwrite_empty)]
|
||||
@ -129,16 +135,15 @@ impl LocalSource {
|
||||
});
|
||||
}
|
||||
|
||||
let with_atime = opts.with_atime;
|
||||
let cache = UsersCache::new();
|
||||
let builder = walk_builder;
|
||||
let walker = builder.build();
|
||||
|
||||
Ok(Self {
|
||||
builder,
|
||||
walker,
|
||||
with_atime,
|
||||
cache,
|
||||
with_atime: opts.with_atime,
|
||||
ignore_devid: opts.ignore_devid,
|
||||
cache: UsersCache::new(),
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -172,12 +177,17 @@ impl Iterator for LocalSource {
|
||||
}
|
||||
item => item,
|
||||
}
|
||||
.map(|e| map_entry(e?, self.with_atime, &self.cache))
|
||||
.map(|e| map_entry(e?, self.with_atime, self.ignore_devid, &self.cache))
|
||||
}
|
||||
}
|
||||
|
||||
// map_entry: turn entry into (Path, Node)
|
||||
fn map_entry(entry: DirEntry, with_atime: bool, cache: &UsersCache) -> Result<(PathBuf, Node)> {
|
||||
fn map_entry(
|
||||
entry: DirEntry,
|
||||
with_atime: bool,
|
||||
ignore_devid: bool,
|
||||
cache: &UsersCache,
|
||||
) -> Result<(PathBuf, Node)> {
|
||||
let name = entry.file_name();
|
||||
let m = entry.metadata()?;
|
||||
|
||||
@ -201,7 +211,7 @@ fn map_entry(entry: DirEntry, with_atime: bool, cache: &UsersCache) -> Result<(P
|
||||
let size = if m.is_dir() { 0 } else { m.len() };
|
||||
let mode = map_mode_to_go(m.mode());
|
||||
let inode = m.ino();
|
||||
let device_id = m.dev();
|
||||
let device_id = if ignore_devid { 0 } else { m.dev() };
|
||||
let links = if m.is_dir() { 0 } else { m.nlink() };
|
||||
|
||||
let meta = Metadata {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user