Skip to content

Commit b845468

Browse files
committed
Fix duplicate detection when using -recurse/having path info
1 parent 565cdfc commit b845468

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>DVUploader</groupId>
66
<artifactId>DVUploader</artifactId>
7-
<version>1.2.0</version>
7+
<version>1.2.1</version>
88
<properties>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1010
</properties>

src/main/java/org/sead/uploader/dataverse/DVUploader.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,8 @@ public String itemExists(String path, Resource item) {
329329
println("out:" + relPath);
330330
}
331331

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

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

441442
@Override
442443
protected String verifyDataByHash(String tagId, String path, Resource item) {
443-
JSONObject checksum = existingItems.get(item.getName());
444+
String sourcepath = (path.startsWith("/") ? "" : path) + item.getName();
445+
446+
JSONObject checksum = existingItems.get(sourcepath);
444447
if (!checksum.getString("value").equals(item.getHash(checksum.getString("type")))) {
445-
hashIssues.put(path + item.getName(), "!!!: A different version of this item exists with ID: " + tagId);
448+
hashIssues.put(sourcepath, "!!!: A different version of this item exists with ID: " + tagId);
446449
return null;
447450
} // else it matches!
448451
return tagId;

0 commit comments

Comments
 (0)