Skip to content

Commit

Permalink
changed image removal on cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Feb 27, 2024
1 parent 292d51a commit 07d36a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion plugin/.project
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,5 @@
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.zeroturnaround.eclipse.jrebelNature</nature>
</natures>
</projectDescription>
12 changes: 10 additions & 2 deletions plugin/src/de/intranda/goobi/plugins/MassUploadPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ public class MassUploadPlugin implements IWorkflowPlugin, IPlugin {
private String[] insertModes = { "plugin_massupload_insertmode_imageName", "plugin_massupload_insertmode_barcode" };
private String insertMode = "plugin_massupload_insertmode_imageName";

// use file upload or insert files from user home
private boolean useUpload;

/**
* Constructor
*/
Expand Down Expand Up @@ -153,6 +156,8 @@ private void readUser() {
* @param event
*/
public void uploadFile(FileUploadEvent event) {
useUpload = true;

try {
if (tempFolder == null) {
readUser();
Expand Down Expand Up @@ -248,6 +253,7 @@ private void saveFileTemporary(String fileName, InputStream in) throws IOExcepti
* do not upload the images from web UI, use images of subfolder in user home directory instead, usually called 'mass_upload'
*/
public void readFilesFromUserHomeFolder() {
useUpload = false;
uploadedFiles = new ArrayList<>();
finishedInserts = new ArrayList<>();
stepIDs = new HashSet<>();
Expand Down Expand Up @@ -283,8 +289,10 @@ public void readFilesFromUserHomeFolder() {
* Cancel the entire process and delete the uploaded files
*/
public void cleanUploadFolder() {
for (MassUploadedFile uploadedFile : uploadedFiles) {
uploadedFile.getFile().delete(); //NOSONAR
if (useUpload) {
for (MassUploadedFile uploadedFile : uploadedFiles) {
uploadedFile.getFile().delete(); //NOSONAR
}
}
uploadedFiles = new ArrayList<>();
finishedInserts = new ArrayList<>();
Expand Down

0 comments on commit 07d36a7

Please sign in to comment.