Merge pull request #9629 from tdonohue/fix_ticket_9499

Ensure work directory is cleaned up even when Zip export fails
This commit is contained in:
Tim Donohue
2024-06-06 09:52:41 -05:00
committed by GitHub

View File

@@ -490,7 +490,7 @@ public class ItemExportServiceImpl implements ItemExportService {
File wkDir = new File(workDir);
if (!wkDir.exists() && !wkDir.mkdirs()) {
logError("Unable to create working direcory");
logError("Unable to create working directory");
}
File dnDir = new File(destDirName);
@@ -498,11 +498,18 @@ public class ItemExportServiceImpl implements ItemExportService {
logError("Unable to create destination directory");
}
// export the items using normal export method
exportItem(context, items, workDir, seqStart, migrate, excludeBitstreams);
try {
// export the items using normal export method (this exports items to our workDir)
exportItem(context, items, workDir, seqStart, migrate, excludeBitstreams);
// now zip up the export directory created above
zip(workDir, destDirName + System.getProperty("file.separator") + zipFileName);
// now zip up the workDir directory created above
zip(workDir, destDirName + System.getProperty("file.separator") + zipFileName);
} finally {
// Cleanup workDir created above, if it still exists
if (wkDir.exists()) {
deleteDirectory(wkDir);
}
}
}
@Override