1
0
mirror of https://github.com/fumiama/terasu-cloudflared.git synced 2026-06-09 20:50:34 +08:00

TUN-3599: improved delete if credentials isnt found.

Tunnel delete is successful even if we don't find the credentials
file in the user's filesystem. We no longer "error" indicating this
is a problem. This fix also enables chaining of the delete command
by removing a pre-mature return if the credentials file is not found.
This commit is contained in:
Sudarsan Reddy
2020-12-04 11:06:13 +00:00
parent 38fb0b28b6
commit 1c0dac77d7
2 changed files with 143 additions and 8 deletions

View File

@@ -228,14 +228,10 @@ func (sc *subcommandContext) delete(tunnelIDs []uuid.UUID) error {
}
credFinder := sc.credentialFinder(id)
tunnelCredentialsPath, err := credFinder.Path()
if err != nil {
sc.logger.Infof("Cannot locate tunnel credentials to delete, error: %v. Please delete the file manually", err)
return nil
}
if err = os.Remove(tunnelCredentialsPath); err != nil {
sc.logger.Infof("Cannot delete tunnel credentials, error: %v. Please delete the file manually", err)
if tunnelCredentialsPath, err := credFinder.Path(); err == nil {
if err = os.Remove(tunnelCredentialsPath); err != nil {
sc.logger.Infof("Tunnel %v was deleted, but we could not remove its credentials file %s: %s. Consider deleting this file manually.", id, tunnelCredentialsPath, err)
}
}
}
return nil