Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes the constraint violation error in DestroyDataseCommand (3875) #3876

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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