kitab

Unnamed repository; edit this file 'description' to name the repository.
Info | Log | Files | Refs | LICENSE

commit 5a96defc871111e0af66982aec8988b8fff45ede
parent 2960a34feeacd9d134c62bc9374a8168f5c02d15
Author: lash <dev@holbrook.no>
Date:   Fri, 16 Sep 2022 18:20:25 +0000

Avoid panic for xattr parse on incompatible filesystem

Diffstat:
Mset.sh | 6++++++
Msrc/meta.rs | 9++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/set.sh b/set.sh @@ -13,6 +13,12 @@ if [ ! -z "$title" ]; then setfattr -n user.dcterms:title -v "$title" "$f" fi +getfattr -n user.dcterms:title "$f" &> /dev/null +if [ "$?" -gt "0" ]; then + >&2 echo no title set, exiting. + exit 0 +fi + echo -n "Author: " read author if [ ! -z "$author" ]; then diff --git a/src/meta.rs b/src/meta.rs @@ -244,7 +244,14 @@ impl MetaData { .into_string() .unwrap(); - let title_src = xattr::get(filepath, "user.dcterms:title").unwrap(); + let title_src = match xattr::get(filepath, "user.dcterms:title") { + Ok(v) => { + v + }, + Err(e) => { + return Err(ParseError{}); + } + }; match title_src { Some(v) => { let s = std::str::from_utf8(&v).unwrap();