Skip to content

Commit

Permalink
Fixes the constraint violation error in DestroyDataseCommand, when th…
Browse files Browse the repository at this point in the history
…e doomed

dataset has an explicitly assigned thumbnail DataFile.
  • Loading branch information
landreev committed Jun 1, 2017
1 parent f6441f8 commit 0ecdd35
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ protected void executeImpl(CommandContext ctxt) throws CommandException {
this, Collections.singleton(Permission.DeleteDatasetDraft), doomed);
}

// If there is a dedicated thumbnail DataFile, it needs to be reset
// explicitly, or we'll get a constraint violation when deleting:
doomed.setThumbnailFile(null);
final Dataset managedDoomed = ctxt.em().merge(doomed);


List<String> datasetAndFileSolrIdsToDelete = new ArrayList<>();
// files need to iterate through and remove 'by hand' to avoid
// optimistic lock issues....
// optimistic lock issues... (plus the physical files need to be
// deleted too!)

Iterator <DataFile> dfIt = doomed.getFiles().iterator();
while (dfIt.hasNext()){
DataFile df = dfIt.next();
Expand Down

0 comments on commit 0ecdd35

Please sign in to comment.