Skip to content

Commit

Permalink
Fix duplicate detection when using -recurse/having path info
Browse files Browse the repository at this point in the history
  • Loading branch information
qqmyers committed Nov 7, 2024
1 parent 565cdfc commit b845468
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>DVUploader</groupId>
<artifactId>DVUploader</artifactId>
<version>1.2.0</version>
<version>1.2.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand Down
9 changes: 6 additions & 3 deletions src/main/java/org/sead/uploader/dataverse/DVUploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ public String itemExists(String path, Resource item) {
println("out:" + relPath);
}

String sourcepath = item.getName();
//Create a path/name string w/o an initial /
String sourcepath = (path.length()==1 ? "" : path.substring(1)) + item.getName();

// One-time: get metadata for dataset to see if it exists and what files it
// contains
Expand Down Expand Up @@ -440,9 +441,11 @@ public String itemExists(String path, Resource item) {

@Override
protected String verifyDataByHash(String tagId, String path, Resource item) {
JSONObject checksum = existingItems.get(item.getName());
String sourcepath = (path.startsWith("/") ? "" : path) + item.getName();

JSONObject checksum = existingItems.get(sourcepath);
if (!checksum.getString("value").equals(item.getHash(checksum.getString("type")))) {
hashIssues.put(path + item.getName(), "!!!: A different version of this item exists with ID: " + tagId);
hashIssues.put(sourcepath, "!!!: A different version of this item exists with ID: " + tagId);
return null;
} // else it matches!
return tagId;
Expand Down

0 comments on commit b845468

Please sign in to comment.