Skip to content

Commit 4790ff6

Browse files
committed
change: remove redundant time.Duration to addServiceAccountsToTempCache function
1 parent b2a486a commit 4790ff6

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

rclone/sa.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func mcacheItemExpired(key string, _ interface{}) {
5454
log.Debugf("Cleared SA from mcache: %s", key)
5555
}
5656

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

225225
return serviceAccounts, err

web/handler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,6 @@ func (ws *Server) ServiceAccountHandler(c *fiber.Ctx) {
8383
// (so if another gclone transfer routine requests within N duration, re-issue the same sa)
8484
ws.saCache.cache[sa[0].ServiceAccountPath] = cacheEntry
8585

86+
// return service account
8687
c.SendString(sa[0].ServiceAccountPath)
8788
}

web/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
/* Const */
1515

1616
const (
17-
maxSaCacheHits int = 6
17+
maxSaCacheHits int = 4
1818
durationSaCacheEntry time.Duration = 10 * time.Second
1919
)
2020

0 commit comments

Comments
 (0)