No longer failing restore if setting file attributes fails

pull/10/head
Dennis Schwerdel 6 years ago
parent 5a6cf4b55b
commit efbd374678

@ -6,6 +6,7 @@ This project follows [semantic versioning](http://semver.org).
### UNRELEASED
- [added] Added CHANGELOG
- [added] Locking local repository to avoid index corruption
- [added] Storing user/group names in backup
- [modified] No longer trying to upload by rename
- [fixed] Creating empty bundle cache on init to avoid warnings
- [fixed] Calling sodiumoxide::init for faster algorithms and thread safety (not needed)

@ -39,26 +39,6 @@ quick_error!{
description("Failed to create entity")
display("Inode error: failed to create entity {:?}\n\tcaused by: {}", path, err)
}
SetPermissions(err: io::Error, path: PathBuf, mode: u32) {
cause(err)
description("Failed to set permissions")
display("Inode error: failed to set permissions to {:3o} on {:?}\n\tcaused by: {}", mode, path, err)
}
SetTimes(err: io::Error, path: PathBuf) {
cause(err)
description("Failed to set file times")
display("Inode error: failed to set file times on {:?}\n\tcaused by: {}", path, err)
}
SetOwnership(err: io::Error, path: PathBuf) {
cause(err)
description("Failed to set file ownership")
display("Inode error: failed to set file ownership on {:?}\n\tcaused by: {}", path, err)
}
SetXattr(err: io::Error, path: PathBuf) {
cause(err)
description("Failed to set xattr")
display("Inode error: failed to set xattr on {:?}\n\tcaused by: {}", path, err)
}
Integrity(reason: &'static str) {
description("Integrity error")
display("Inode error: inode integrity error: {}", reason)
@ -225,21 +205,26 @@ impl Inode {
}
}
let time = FileTime::from_seconds_since_1970(self.timestamp as u64, 0);
try!(filetime::set_file_times(&full_path, time, time).map_err(|e| InodeError::SetTimes(e, full_path.clone())));
if let Err(err) = filetime::set_file_times(&full_path, time, time) {
warn!("Failed to set file time on {:?}: {}", full_path, err);
}
if !self.xattrs.is_empty() {
if xattr::SUPPORTED_PLATFORM {
for (name, data) in &self.xattrs {
try!(xattr::set(&full_path, name, data).map_err(|e| InodeError::SetXattr(e, full_path.clone())))
if let Err(err) = xattr::set(&full_path, name, data) {
warn!("Failed to set xattr {} on {:?}: {}", name, full_path, err);
}
}
} else {
warn!("Not setting xattr on {:?}", full_path);
}
}
try!(fs::set_permissions(
&full_path,
Permissions::from_mode(self.mode)
).map_err(|e| InodeError::SetPermissions(e, full_path.clone(), self.mode)));
try!(chown(&full_path, self.user, self.group).map_err(|e| InodeError::SetOwnership(e, full_path.clone())));
if let Err(err) = fs::set_permissions(&full_path, Permissions::from_mode(self.mode)) {
warn!("Failed to set permissions {:o} on {:?}: {}", self.mode, full_path, err);
}
if let Err(err) = chown(&full_path, self.user, self.group) {
warn!("Failed to set user {} and group {} on {:?}: {}", self.user, self.group, full_path, err);
}
Ok(file)
}

@ -12,7 +12,8 @@ mod linux {
let result = unsafe { libc::lchown((&path).as_ptr(), uid, gid) };
match result {
0 => Ok(()),
err => Err(io::Error::from_raw_os_error(err))
-1 => Err(io::Error::last_os_error()),
_ => unreachable!()
}
}
}

Loading…
Cancel
Save