Skip to content

Commit

Permalink
Fix the cleanup of local secret file (#5061)
Browse files Browse the repository at this point in the history

Signed-off-by: Paolo Di Tommaso <[email protected]>
Signed-off-by: Dr Marco Claudio De La Pierre <[email protected]>
Co-authored-by: Dr Marco Claudio De La Pierre <[email protected]>
  • Loading branch information
pditommaso and marcodelapierre authored Jun 17, 2024
1 parent 38434b8 commit e28537c
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import nextflow.Const
import nextflow.SysEnv
import nextflow.exception.AbortOperationException
import nextflow.exception.ProcessUnrecoverableException
import nextflow.util.CacheHelper
import nextflow.util.Escape
/**
* Implements a secrets store that saves secrets into a JSON file save into the
Expand Down Expand Up @@ -198,11 +197,13 @@ class LocalSecretsProvider implements SecretsProvider, Closeable {
if( !secretsMap )
return null

final name = ".nf-${CacheHelper.hasher(secretsMap.values()).hash()}.secrets"
final name = ".nf-${UUID.randomUUID().toString()}.secrets"
final path = storeFile.parent.resolve(name)
if( path.exists() ) {
// make sure the file can only be accessed by the owner user
path.setPermissions(ONLY_OWNER_PERMS)
// remove it on completion
path.toFile().deleteOnExit()
return path
}

Expand All @@ -215,6 +216,9 @@ class LocalSecretsProvider implements SecretsProvider, Closeable {
// make sure the file can only be accessed by the owner user
path.setPermissions(ONLY_OWNER_PERMS)
path.text = result
// remove it on completion
path.toFile().deleteOnExit()
// return the temp path
return path
}
}

0 comments on commit e28537c

Please sign in to comment.