Skip to content

Commit

Permalink
not overwrite existing file if same as tar entry (#3)
Browse files Browse the repository at this point in the history
* Upgrade Jena version to 3.16.0 (vivo-project#196)

Related to: https://jira.lyrasis.org/browse/VIVO-1943

* remove example-settings.xml
* update home directory untar non-destructive
* checksum digest to retain modified files
* compare checksum from digest with existing file
* overwrite files that have not changed
* add command to manually generate checksum digest
* simplify parsing checksum digest using pattern
* do not overwrite file if same as already exists

Co-authored-by: Andrew Woods <awoods@lyrasis.org>
Co-authored-by: Andrew Woods <awoods@duraspace.org>
  • Loading branch information
3 people committed Feb 4, 2021
1 parent c4ae002 commit 4959898
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,16 @@ private Map<String, String> 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) {
Expand Down

0 comments on commit 4959898

Please sign in to comment.