Cache xattr values so that metadata works as expected at least for the current session even if xattr is not supported by the filesystem and thus metadata can't be persisted

This commit is contained in:
Reinhard Pointner 2016-03-27 17:58:01 +00:00
parent d70e82401e
commit 8d35a67d71
1 changed files with 4 additions and 2 deletions

View File

@ -54,8 +54,7 @@ public class XattrMetaInfo {
public synchronized Object getMetaInfo(File file) {
return getCachedValue(xattrMetaInfoCache, file, key -> {
Object metadata = xattr(file).getObject();
return isMetaInfo(metadata) ? metadata : null;
return xattr(file).getObject();
});
}
@ -108,12 +107,15 @@ public class XattrMetaInfo {
try {
if (isMetaInfo(model)) {
xattrMetaInfoCache.put(file, model);
if (useExtendedFileAttributes) {
xattr.get().setObject(model);
}
}
if (original != null && original.length() > 0 && getOriginalName(file) == null) {
xattrOriginalNameCache.put(file, original);
if (useExtendedFileAttributes) {
xattr.get().setOriginalName(original);
}