Skip to content

Commit

Permalink
Merge pull request #7016 from IQSS/6948-duplicate-file-name
Browse files Browse the repository at this point in the history
#6948 check file labels on new draft
  • Loading branch information
kcondon committed Jul 2, 2020
2 parents bd736d2 + b72fb31 commit 2f193c1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/java/edu/harvard/iq/dataverse/Dataset.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ private DatasetVersion createNewDatasetVersion(Template template, FileMetadata f
newFm.setDataFile(fm.getDataFile());
newFm.setDatasetVersion(dsv);
newFm.setProvFreeForm(fm.getProvFreeForm());
newFm.setInPriorVersion(true);

//fmVarMet would be updated in DCT
if ((fmVarMet != null && !fmVarMet.getId().equals(fm.getId())) || (fmVarMet == null)) {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/FileMetadata.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,17 @@ public Long getVersion() {
public void setVersion(Long version) {
this.version = version;
}

@Transient
private boolean inPriorVersion;

public boolean isInPriorVersion() {
return inPriorVersion;
}

public void setInPriorVersion(boolean inPriorVersion) {
this.inPriorVersion = inPriorVersion;
}

@Transient
private boolean selected;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,10 @@ private static Set<String> existingPathNamesAsSet(DatasetVersion version, FileMe
// create list of existing path names from all FileMetadata in the DatasetVersion
// (skipping the one specified fileMetadata, if supplied. That's in order to
// be able to call this method
// #6942 added proxy for existing files to a boolean set when dataset version copy is done
for (Iterator<FileMetadata> fmIt = version.getFileMetadatas().iterator(); fmIt.hasNext();) {
FileMetadata fm = fmIt.next();
if (fm.getId() != null && (fileMetadata == null || !fm.getId().equals(fileMetadata.getId()))) {
if ((fm.isInPriorVersion() || fm.getId() != null) && (fileMetadata == null || !fm.getId().equals(fileMetadata.getId()))) {
String existingName = fm.getLabel();
String existingDir = fm.getDirectoryLabel();

Expand Down

0 comments on commit 2f193c1

Please sign in to comment.