From 3d72aee1b2395971dd0b07e7379f878554160737 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Ketelaars?= Date: Sat, 25 Mar 2023 07:58:23 +0100 Subject: [PATCH] OpenBSD does not support extended file attributes --- Cargo.toml | 2 ++ changelog/new.txt | 1 + src/backend/ignore.rs | 24 +++++++++++++++--------- src/backend/local.rs | 4 ++-- 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 171d9c5..130dd4a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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] diff --git a/changelog/new.txt b/changelog/new.txt index f2f6a60..cf20515 100644 --- a/changelog/new.txt +++ b/changelog/new.txt @@ -3,5 +3,6 @@ Changes in version x.x.x: Breaking changes: Bugs fixed: +- Fixed compiliation on OpenBSD. New features: diff --git a/src/backend/ignore.rs b/src/backend/ignore.rs index 64f1d1f..fe6ac97 100644 --- a/src/backend/ignore.rs +++ b/src/backend/ignore.rs @@ -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::>()?; + .collect::>()? + }; let meta = Metadata { size, diff --git a/src/backend/local.rs b/src/backend/local.rs index ed1b312..36a8980 100644 --- a/src/backend/local.rs +++ b/src/backend/local.rs @@ -324,7 +324,7 @@ impl LocalDestination { Ok(()) } - #[cfg(windows)] + #[cfg(any(windows, target_os = "openbsd"))] pub fn set_extended_attributes( &self, _item: impl AsRef, @@ -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,