Merge pull request #532 from bket/fix_build_openbsd

OpenBSD does not support extended file attributes
This commit is contained in:
aawsome 2023-03-25 20:35:44 +01:00 committed by GitHub
commit cd356e9146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 11 deletions

View File

@ -91,6 +91,8 @@ rhai = {version = "1.13", features = ["sync", "serde", "no_optimize", "no_module
[target.'cfg(not(windows))'.dependencies]
users = "0.11"
[target.'cfg(not(any(windows, target_os="openbsd")))'.dependencies]
xattr = "1"
[dev-dependencies]

View File

@ -3,6 +3,7 @@ Changes in version x.x.x:
Breaking changes:
Bugs fixed:
- Fixed compiliation on OpenBSD.
New features:
- REST backend: Set User-Agent header

View File

@ -17,7 +17,7 @@ use serde_with::{serde_as, DisplayFromStr};
#[cfg(not(windows))]
use users::{Groups, Users, UsersCache};
#[cfg(not(windows))]
#[cfg(not(any(windows, target_os = "openbsd")))]
use super::node::ExtendedAttribute;
use super::node::{Metadata, NodeType};
use super::{Node, ReadSource, ReadSourceEntry, ReadSourceOpen};
@ -325,15 +325,21 @@ fn map_entry(
let device_id = if ignore_devid { 0 } else { m.dev() };
let links = if m.is_dir() { 0 } else { m.nlink() };
let path = entry.path();
let extended_attributes = xattr::list(path)?
.map(|name| {
Ok(ExtendedAttribute {
name: name.to_string_lossy().to_string(),
value: xattr::get(path, name)?.unwrap(),
#[cfg(target_os = "openbsd")]
let extended_attributes = vec![];
#[cfg(not(target_os = "openbsd"))]
let extended_attributes = {
let path = entry.path();
xattr::list(path)?
.map(|name| {
Ok(ExtendedAttribute {
name: name.to_string_lossy().to_string(),
value: xattr::get(path, name)?.unwrap(),
})
})
})
.collect::<Result<_>>()?;
.collect::<Result<_>>()?
};
let meta = Metadata {
size,

View File

@ -324,7 +324,7 @@ impl LocalDestination {
Ok(())
}
#[cfg(windows)]
#[cfg(any(windows, target_os = "openbsd"))]
pub fn set_extended_attributes(
&self,
_item: impl AsRef<Path>,
@ -333,7 +333,7 @@ impl LocalDestination {
Ok(())
}
#[cfg(not(windows))]
#[cfg(not(any(windows, target_os = "openbsd")))]
pub fn set_extended_attributes(
&self,
item: impl AsRef<Path>,