mirror of
git://git.proxmox.com/git/proxmox-backup.git
synced 2025-01-07 17:18:03 +03:00
datastore: list images: reduce indentation depth on error checking
Simply pull out the inner IO error and the affected path first. Clean up style-wise a bit while touching this anyway, but no semantic change intended. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
6d5b559bdb
commit
5b16dffcf2
@ -867,26 +867,22 @@ impl DataStore {
|
||||
.unwrap_or(false)
|
||||
}
|
||||
let handle_entry_err = |err: walkdir::Error| {
|
||||
if let Some(inner) = err.io_error() {
|
||||
if let Some(path) = err.path() {
|
||||
if inner.kind() == io::ErrorKind::PermissionDenied {
|
||||
// only allow to skip ext4 fsck directory, avoid GC if, for example,
|
||||
// a user got file permissions wrong on datastore rsync to new server
|
||||
if err.depth() > 1 || !path.ends_with("lost+found") {
|
||||
bail!("cannot continue garbage-collection safely, permission denied on: {:?}", path)
|
||||
}
|
||||
} else {
|
||||
bail!(
|
||||
"unexpected error on datastore traversal: {} - {:?}",
|
||||
inner,
|
||||
path
|
||||
)
|
||||
}
|
||||
} else {
|
||||
bail!("unexpected error on datastore traversal: {}", inner)
|
||||
// first, extract the actual IO error and the affected path
|
||||
let (inner, path) = match (err.io_error(), err.path()) {
|
||||
(None, _) => return Ok(()), // not an IO-error
|
||||
(Some(inner), Some(path)) => (inner, path),
|
||||
(Some(inner), None) => bail!("unexpected error on datastore traversal: {inner}"),
|
||||
};
|
||||
if inner.kind() == io::ErrorKind::PermissionDenied {
|
||||
if err.depth() == 0 && path.ends_with("lost+found") {
|
||||
// allow skipping ext4 fsck-directory on EPERM only, otherwise we might prune
|
||||
// too many chunks. E.g., if users messed up with owner/perms on a rsync
|
||||
return Ok(());
|
||||
}
|
||||
bail!("cannot continue garbage-collection safely, permission denied on: {path:?}");
|
||||
} else {
|
||||
bail!("unexpected error on datastore traversal: {inner} - {path:?}");
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
for entry in walker.filter_entry(|e| !is_hidden(e)) {
|
||||
let path = match entry {
|
||||
|
Loading…
Reference in New Issue
Block a user