diff --git a/rclone/sa.go b/rclone/sa.go index e1b3d77..3008366 100644 --- a/rclone/sa.go +++ b/rclone/sa.go @@ -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) } @@ -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 diff --git a/web/handler.go b/web/handler.go index d6f83a0..63a1035 100644 --- a/web/handler.go +++ b/web/handler.go @@ -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) } diff --git a/web/server.go b/web/server.go index 192bfae..0e6cc6d 100644 --- a/web/server.go +++ b/web/server.go @@ -14,7 +14,7 @@ import ( /* Const */ const ( - maxSaCacheHits int = 6 + maxSaCacheHits int = 4 durationSaCacheEntry time.Duration = 10 * time.Second )