Skip to content

Commit b90bd2e

Browse files
authored
Merge branch 'main' into throttle
2 parents 98499c2 + 0842992 commit b90bd2e

27 files changed

+3367
-122
lines changed

crates/backend/src/error.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::doc_markdown)]
12
use std::{num::TryFromIntError, process::ExitStatus, str::Utf8Error};
23

34
use displaydoc::Display;

crates/core/src/archiver.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Archiver<'a, BE: DecryptFullBackend, I: ReadGlobalIndex> {
4040
/// The parent snapshot to use.
4141
parent: Parent,
4242

43-
/// The SharedIndexer is used to index the data.
43+
/// The `SharedIndexer` is used to index the data.
4444
indexer: SharedIndexer<BE>,
4545

4646
/// The backend to write to.
@@ -49,7 +49,7 @@ pub struct Archiver<'a, BE: DecryptFullBackend, I: ReadGlobalIndex> {
4949
/// The backend to write to.
5050
index: &'a I,
5151

52-
/// The SnapshotFile to write to.
52+
/// The `SnapshotFile` to write to.
5353
snap: SnapshotFile,
5454
}
5555

crates/core/src/archiver/parent.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl Parent {
279279
let parent = match parent {
280280
ParentResult::Matched(p_node) => {
281281
if p_node.content.iter().flatten().all(|id| index.has_data(id)) {
282-
node.content = p_node.content.clone();
282+
node.content.clone_from(&p_node.content);
283283
ParentResult::Matched(())
284284
} else {
285285
warn!(

crates/core/src/backend/ignore.rs

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ impl LocalSource {
167167
for line in std::fs::read_to_string(file)
168168
.map_err(|err| IgnoreErrorKind::ErrorGlob {
169169
file: file.into(),
170-
err,
170+
source: err,
171171
})?
172172
.lines()
173173
{
@@ -190,7 +190,7 @@ impl LocalSource {
190190
for line in std::fs::read_to_string(file)
191191
.map_err(|err| IgnoreErrorKind::ErrorGlob {
192192
file: file.into(),
193-
err,
193+
source: err,
194194
})?
195195
.lines()
196196
{
@@ -260,8 +260,13 @@ impl ReadSourceOpen for OpenFile {
260260
/// [`IgnoreErrorKind::UnableToOpenFile`]: crate::error::IgnoreErrorKind::UnableToOpenFile
261261
fn open(self) -> RusticResult<Self::Reader> {
262262
let path = self.0;
263-
File::open(&path)
264-
.map_err(|err| IgnoreErrorKind::UnableToOpenFile { file: path, err }.into())
263+
File::open(&path).map_err(|err| {
264+
IgnoreErrorKind::UnableToOpenFile {
265+
file: path,
266+
source: err,
267+
}
268+
.into()
269+
})
265270
}
266271
}
267272

@@ -329,7 +334,7 @@ impl Iterator for LocalSourceWalker {
329334
self.save_opts.with_atime,
330335
self.save_opts.ignore_devid,
331336
)
332-
.map_err(std::convert::Into::into)
337+
.map_err(Into::into)
333338
})
334339
}
335340
}
@@ -410,7 +415,7 @@ fn map_entry(
410415
let path = entry.path();
411416
let target = read_link(path).map_err(|err| IgnoreErrorKind::ErrorLink {
412417
path: path.to_path_buf(),
413-
err,
418+
source: err,
414419
})?;
415420
let node_type = NodeType::from_link(&target);
416421
Node::new_node(name, node_type, meta)
@@ -535,15 +540,15 @@ fn map_entry(
535540
xattr::list(path)
536541
.map_err(|err| IgnoreErrorKind::ErrorXattr {
537542
path: path.to_path_buf(),
538-
err,
543+
source: err,
539544
})?
540545
.map(|name| {
541546
Ok(ExtendedAttribute {
542547
name: name.to_string_lossy().to_string(),
543548
value: xattr::get(path, name)
544549
.map_err(|err| IgnoreErrorKind::ErrorXattr {
545550
path: path.to_path_buf(),
546-
err,
551+
source: err,
547552
})?
548553
.unwrap(),
549554
})
@@ -574,7 +579,7 @@ fn map_entry(
574579
let path = entry.path();
575580
let target = read_link(path).map_err(|err| IgnoreErrorKind::ErrorLink {
576581
path: path.to_path_buf(),
577-
err,
582+
source: err,
578583
})?;
579584
let node_type = NodeType::from_link(&target);
580585
Node::new_node(name, node_type, meta)

crates/core/src/backend/local_destination.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ impl LocalDestination {
330330

331331
if let Some(mode) = node.meta.mode {
332332
let mode = map_mode_from_go(mode);
333-
std::fs::set_permissions(filename, fs::Permissions::from_mode(mode))
333+
fs::set_permissions(filename, fs::Permissions::from_mode(mode))
334334
.map_err(LocalDestinationErrorKind::SettingFilePermissionsFailed)?;
335335
}
336336
Ok(())
@@ -390,9 +390,12 @@ impl LocalDestination {
390390
let filename = self.path(item);
391391
let mut done = vec![false; extended_attributes.len()];
392392

393-
for curr_name in xattr::list(&filename)
394-
.map_err(|err| LocalDestinationErrorKind::ListingXattrsFailed(err, filename.clone()))?
395-
{
393+
for curr_name in xattr::list(&filename).map_err(|err| {
394+
LocalDestinationErrorKind::ListingXattrsFailed {
395+
source: err,
396+
path: filename.clone(),
397+
}
398+
})? {
396399
match extended_attributes.iter().enumerate().find(
397400
|(_, ExtendedAttribute { name, .. })| name == curr_name.to_string_lossy().as_ref(),
398401
) {
@@ -660,7 +663,7 @@ impl LocalDestination {
660663
/// [`LocalDestinationErrorKind::CouldNotWriteToBuffer`]: crate::error::LocalDestinationErrorKind::CouldNotWriteToBuffer
661664
pub fn write_at(&self, item: impl AsRef<Path>, offset: u64, data: &[u8]) -> RusticResult<()> {
662665
let filename = self.path(item);
663-
let mut file = fs::OpenOptions::new()
666+
let mut file = OpenOptions::new()
664667
.create(true)
665668
.truncate(false)
666669
.write(true)

crates/core/src/blob/packer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ impl PackSizer {
160160
#[allow(clippy::struct_field_names)]
161161
#[derive(Clone)]
162162
pub struct Packer<BE: DecryptWriteBackend> {
163-
/// The raw packer wrapped in an Arc and RwLock.
163+
/// The raw packer wrapped in an `Arc` and `RwLock`.
164164
// This is a hack: raw_packer and indexer are only used in the add_raw() method.
165165
// TODO: Refactor as actor, like the other add() methods
166166
raw_packer: Arc<RwLock<RawPacker<BE>>>,

crates/core/src/blob/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -824,7 +824,7 @@ pub(crate) fn merge_trees(
824824

825825
let mut tree_iters: Vec<_> = trees
826826
.iter()
827-
.map(|id| Tree::from_backend(be, index, *id).map(std::iter::IntoIterator::into_iter))
827+
.map(|id| Tree::from_backend(be, index, *id).map(IntoIterator::into_iter))
828828
.collect::<RusticResult<_>>()?;
829829

830830
// fill Heap with first elements from all trees

crates/core/src/commands/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub struct ConfigOptions {
125125
pub set_treepack_size: Option<ByteSize>,
126126

127127
/// Set upper limit for default packsize for tree packs.
128-
/// Note that packs actually can get up to some MiBs larger.
128+
/// Note that packs actually can get a bit larger.
129129
/// If not set, pack sizes can grow up to approximately `4 GiB`.
130130
#[cfg_attr(feature = "clap", clap(long, value_name = "SIZE"))]
131131
pub set_treepack_size_limit: Option<ByteSize>,
@@ -151,7 +151,7 @@ pub struct ConfigOptions {
151151
pub set_datapack_growfactor: Option<u32>,
152152

153153
/// Set upper limit for default packsize for tree packs.
154-
/// Note that packs actually can get up to some MiBs larger.
154+
/// Note that packs actually can get a bit larger.
155155
/// If not set, pack sizes can grow up to approximately `4 GiB`.
156156
#[cfg_attr(feature = "clap", clap(long, value_name = "SIZE"))]
157157
pub set_datapack_size_limit: Option<ByteSize>,

crates/core/src/commands/repair/index.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -85,21 +85,21 @@ impl RepairIndexOptions {
8585
);
8686
for (id, size_hint, packsize) in pack_read_header {
8787
debug!("reading pack {id}...");
88-
let pack = IndexPack {
89-
id,
90-
blobs: match PackHeader::from_file(be, id, size_hint, packsize) {
91-
Err(err) => {
92-
warn!("error reading pack {id} (not processed): {err}");
93-
Vec::new()
88+
match PackHeader::from_file(be, id, size_hint, packsize) {
89+
Err(err) => {
90+
warn!("error reading pack {id} (-> removing from index): {err}");
91+
}
92+
Ok(header) => {
93+
let pack = IndexPack {
94+
blobs: header.into_blobs(),
95+
id,
96+
..Default::default()
97+
};
98+
if !dry_run {
99+
// write pack file to index - without the delete mark
100+
indexer.write().unwrap().add_with(pack, false)?;
94101
}
95-
Ok(header) => header.into_blobs(),
96-
},
97-
..Default::default()
98-
};
99-
100-
if !dry_run {
101-
// write pack file to index - without the delete mark
102-
indexer.write().unwrap().add_with(pack, false)?;
102+
}
103103
}
104104
p.inc(1);
105105
}

crates/core/src/commands/restore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ impl BlobLocation {
595595
self.uncompressed_length
596596
.map_or(
597597
self.length - 32, // crypto overhead
598-
std::num::NonZeroU32::get,
598+
NonZeroU32::get,
599599
)
600600
.into()
601601
}

0 commit comments

Comments
 (0)