1
0
mirror of https://github.com/mitb-archive/filebot synced 2025-03-10 06:20:27 -04:00

Force and Restore source last modified timestamp only if it was (possibly) changed by writing xattr metadata

This commit is contained in:
Reinhard Pointner 2019-01-08 22:57:56 +07:00
parent d194ebee73
commit 86391a7f78

View File

@ -676,20 +676,22 @@ public class CmdlineOperations implements CmdlineInterface {
if (matches != null) { if (matches != null) {
for (Match<File, ?> match : matches) { for (Match<File, ?> match : matches) {
if (match.getCandidate() != null) { if (match.getCandidate() != null) {
File destination = log.get(match.getValue()); File source = match.getValue();
if (destination != null && destination.isFile()) { File destination = log.get(source);
xattr.setMetaInfo(destination, match.getCandidate(), match.getValue().getName());
}
}
}
}
// preserve Last Modified date if (destination != null && destination.isFile()) {
log.forEach((source, destination) -> { // remember Last Modified date
if (destination != null && destination.isFile() && source.exists()) { long timestamp = source.isFile() ? source.lastModified() : destination.lastModified();
destination.setLastModified(source.lastModified());
// store xattr
xattr.setMetaInfo(destination, match.getCandidate(), match.getValue().getName());
// restore Last Modified date
destination.setLastModified(timestamp);
}
}
}
} }
});
} }
protected File nextAvailableIndexedName(File file) { protected File nextAvailableIndexedName(File file) {