1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-12-22 15:58:52 -05:00

Read and cache EXIF metadata only once while preserving File-mode backwards-compatibility

This commit is contained in:
Reinhard Pointner 2018-08-04 22:40:13 +07:00
parent 7ab9bb779c
commit 0d8d007ef4
2 changed files with 19 additions and 1 deletions

View File

@ -53,6 +53,7 @@ import net.filebot.Settings;
import net.filebot.hash.HashType;
import net.filebot.media.FFProbe;
import net.filebot.media.ImageMetadata;
import net.filebot.media.LocalDatasource.PhotoFile;
import net.filebot.media.MetaAttributes;
import net.filebot.media.PlexNamingStandard;
import net.filebot.media.VideoFormat;
@ -945,6 +946,9 @@ public class MediaBindingBean {
@Define("photo")
public ImageMetadata getPhoto() throws Exception {
if (infoObject instanceof PhotoFile) {
return ((PhotoFile) infoObject).getMetadata();
}
return new ImageMetadata((File) infoObject);
}

View File

@ -73,7 +73,7 @@ public enum LocalDatasource implements Datasource {
try {
ImageMetadata metadata = new ImageMetadata(f);
if (metadata.getDateTaken().isPresent()) {
exifMap.put(f, f); // photo mode is the same as generic file mode (but only select photo files)
exifMap.put(f, new PhotoFile(f, metadata)); // photo mode is the same as generic file mode (but only select photo files)
} else if (!strict) {
exifMap.put(f, f);
}
@ -90,4 +90,18 @@ public enum LocalDatasource implements Datasource {
// enable xattr regardless of -DuseExtendedFileAttributes system properties
private static final XattrMetaInfo xattr = new XattrMetaInfo(true, false);
public static class PhotoFile extends File {
private final ImageMetadata metadata;
public PhotoFile(File file, ImageMetadata metadata) {
super(file.getPath());
this.metadata = metadata;
}
public ImageMetadata getMetadata() {
return metadata;
}
}
}