diff --git a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java index 749e0440dd..476d8c1a67 100644 --- a/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java +++ b/api/src/main/java/edu/cornell/mannlib/vitro/webapp/application/VitroHomeDirectory.java @@ -128,13 +128,16 @@ private Map untar(File destination) { // reading bytes into memory to avoid having to unreliably reset stream byte[] bytes = IOUtils.toByteArray(tarInput); - digest.put(outFilename, checksum(bytes)); + String newFileChecksum = checksum(bytes); + digest.put(outFilename, newFileChecksum); // if file already exists and stored digest contains the file, // check to determine if it has changed if (outFile.exists() && storedDigest.containsKey(outFilename)) { - // if file has not changed, overwrite - write = storedDigest.get(outFilename).equals(checksum(outFile)); + String existingFileChecksum = checksum(outFile); + // if file has not changed and is not the same as new file, overwrite + write = storedDigest.get(outFilename).equals(existingFileChecksum) + && !existingFileChecksum.equals(newFileChecksum); } if (write) {