Skip to content

Commit

Permalink
Fix Only close the cache db if it is not null (nextflow-io#5631)
Browse files Browse the repository at this point in the history

Signed-off-by: Rob Syme <[email protected]>
Co-authored-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
robsyme and pditommaso authored Jan 9, 2025
1 parent 884f745 commit 9386082
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions modules/nextflow/src/main/groovy/nextflow/Session.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1209,10 +1209,8 @@ class Session implements ISession {
if( aborted || cancelled || error )
return

CacheDB db = null
try {
log.trace "Cleaning-up workdir"
db = CacheFactory.create(uniqueId, runName).openForRead()
log.trace "Cleaning-up workdir"
try (CacheDB db = CacheFactory.create(uniqueId, runName).openForRead()) {
db.eachRecord { HashCode hash, TraceRecord record ->
def deleted = db.removeTaskEntry(hash)
if( deleted ) {
Expand All @@ -1223,10 +1221,7 @@ class Session implements ISession {
log.trace "Clean workdir complete"
}
catch( Exception e ) {
log.warn("Failed to cleanup work dir: ${workDir.toUriString()}")
}
finally {
db.close()
log.warn("Failed to cleanup work dir: ${workDir.toUriString()}", e)
}
}

Expand Down

0 comments on commit 9386082

Please sign in to comment.