Skip to content

Commit

Permalink
change: remove redundant time.Duration to addServiceAccountsToTempCac…
Browse files Browse the repository at this point in the history
…he function
  • Loading branch information
l3uddz committed May 17, 2020
1 parent b2a486a commit 4790ff6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
6 changes: 3 additions & 3 deletions rclone/sa.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func mcacheItemExpired(key string, _ interface{}) {
log.Debugf("Cleared SA from mcache: %s", key)
}

func addServiceAccountsToTempCache(serviceAccounts []*RemoteServiceAccount, duration time.Duration) {
func addServiceAccountsToTempCache(serviceAccounts []*RemoteServiceAccount) {
for _, sa := range serviceAccounts {
mcache.Set(sa.ServiceAccountPath, nil)
}
Expand Down Expand Up @@ -218,8 +218,8 @@ func (m *ServiceAccountManager) GetServiceAccount(remotePaths ...string) ([]*Rem
// were service accounts found?
if err == nil && m.parallelism > 1 && len(serviceAccounts) > 0 {
// there may be multiple routines requesting service accounts
// prevent service account from being re-used (unless explicitly removed by a successful operation)
addServiceAccountsToTempCache(serviceAccounts, 24*time.Hour)
// attempt to prevent service account from being re-used (unless explicitly removed by a successful operation)
addServiceAccountsToTempCache(serviceAccounts)
}

return serviceAccounts, err
Expand Down
1 change: 1 addition & 0 deletions web/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,6 @@ func (ws *Server) ServiceAccountHandler(c *fiber.Ctx) {
// (so if another gclone transfer routine requests within N duration, re-issue the same sa)
ws.saCache.cache[sa[0].ServiceAccountPath] = cacheEntry

// return service account
c.SendString(sa[0].ServiceAccountPath)
}
2 changes: 1 addition & 1 deletion web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
/* Const */

const (
maxSaCacheHits int = 6
maxSaCacheHits int = 4
durationSaCacheEntry time.Duration = 10 * time.Second
)

Expand Down

0 comments on commit 4790ff6

Please sign in to comment.