Skip to content

Commit

Permalink
#155: ao10: fixed move photo(s) with and without autoprocessing
Browse files Browse the repository at this point in the history
  • Loading branch information
k3b committed Feb 18, 2021
1 parent 9d4a52e commit 7bc71e5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@ public PhotoPropertiesUpdateHandler applyChanges(IFile inFilePath, IFile outFile
if (!sameFile || (changed != null)) {
debugExif(sb, "assign ", exifHandler, inFilePath);

IFile jpgFileDir = null;
String jpgFileNameDeleted = null;
if (!sameFile && deleteOriginalWhenFinished) {
jpgFileDir = inFilePath.getParentFile();
jpgFileNameDeleted = inFilePath.getName();
}

exifHandler.save("PhotoPropertiesUpdateHandler save");

Expand All @@ -129,7 +135,7 @@ public PhotoPropertiesUpdateHandler applyChanges(IFile inFilePath, IFile outFile
inFilePath.setLastModified(lastModified);
}

if (sb != null) {
if (sb != null && inFilePath.exists()) {
PhotoPropertiesUpdateHandler exifVerify = PhotoPropertiesUpdateHandler.create(inFilePath,
null, deleteOriginalWhenFinished, "dbg in PhotoPropertiesUpdateHandler", true, true, false);
debugExif(sb, "new ", exifVerify, inFilePath);
Expand All @@ -147,11 +153,12 @@ public PhotoPropertiesUpdateHandler applyChanges(IFile inFilePath, IFile outFile
}
}

if (!sameFile && deleteOriginalWhenFinished) {
IFile delete = XmpFile.getSidecar(inFilePath, false);
if (jpgFileNameDeleted != null) {
// jpg deleted: Also delete corresponding xmp-s if exist
IFile delete = XmpFile.getSidecar(jpgFileDir, jpgFileNameDeleted, false);
deleteFile(delete);

delete = XmpFile.getSidecar(inFilePath, true);
delete = XmpFile.getSidecar(jpgFileDir, jpgFileNameDeleted, true);
deleteFile(delete);

delete = inFilePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public class PhotoPropertiesUpdateHandler extends PhotoPropertiesWrapper
implements IPhotoProperties, IPhotoPropertyFileWriter {
private static final Logger logger = LoggerFactory.getLogger(LibGlobal.LOG_TAG);

private ExifInterfaceEx exif; // not null if exif changes are written to jpg file
private PhotoPropertiesXmpSegment xmp; // not null if exif changes are written to xmp sidecar file.
private final ExifInterfaceEx exif; // not null if exif changes are written to jpg file
private final PhotoPropertiesXmpSegment xmp; // not null if exif changes are written to xmp sidecar file.
private IFile jpgInFile; // where changes are read from.
private IFile jpgOutFile; // where changes are written to. Null meanst same as input
private boolean deleteOriginalAfterFinish; // true: after save original jpg/mxp are deleted (move instead of copy)
private long dbgLoadEndTimestamp;
private long dbgLoadEndTimestamp;

private PhotoPropertiesUpdateHandler(
IPhotoProperties readChild, IPhotoProperties writeChild,
Expand Down Expand Up @@ -108,6 +108,7 @@ protected static PhotoPropertiesUpdateHandler create(
if (LibGlobal.debugEnabledJpgMetaIo) {
startTimestamp = new Date().getTime();
}

PhotoPropertiesXmpSegment xmp = PhotoPropertiesXmpSegment.loadXmpSidecarContentOrNull(jpgInFile, dbg_context);
if ((xmp == null) && (createXmpIfNotExist || PhotoPropertiesUtil.isImage(jpgInFile,
PhotoPropertiesUtil.IMG_TYPE_COMPRESSED_NON_JPG | PhotoPropertiesUtil.IMG_TYPE_UNCOMPRESSED_NON_JPG))) {
Expand Down

0 comments on commit 7bc71e5

Please sign in to comment.