diff --git a/backend/internal/handler/admin/account_handler.go b/backend/internal/handler/admin/account_handler.go index 58715706..78b71431 100644 --- a/backend/internal/handler/admin/account_handler.go +++ b/backend/internal/handler/admin/account_handler.go @@ -1023,6 +1023,10 @@ func (h *AccountHandler) RefreshTier(c *gin.Context) { } tierID, storageInfo, err := h.geminiOAuthService.FetchGoogleOneTier(c.Request.Context(), accessToken, proxyURL) + if err != nil { + response.ErrorFrom(c, err) + return + } if account.Extra == nil { account.Extra = make(map[string]any) @@ -1044,10 +1048,10 @@ func (h *AccountHandler) RefreshTier(c *gin.Context) { } response.Success(c, gin.H{ - "tier_id": tierID, - "drive_storage_limit": account.Extra["drive_storage_limit"], - "drive_storage_usage": account.Extra["drive_storage_usage"], - "updated_at": account.Extra["drive_tier_updated_at"], + "tier_id": tierID, + "drive_storage_limit": account.Extra["drive_storage_limit"], + "drive_storage_usage": account.Extra["drive_storage_usage"], + "updated_at": account.Extra["drive_tier_updated_at"], }) } diff --git a/backend/internal/pkg/geminicli/drive_client.go b/backend/internal/pkg/geminicli/drive_client.go index 5a959fac..79d6835f 100644 --- a/backend/internal/pkg/geminicli/drive_client.go +++ b/backend/internal/pkg/geminicli/drive_client.go @@ -22,17 +22,11 @@ type DriveClient interface { GetStorageQuota(ctx context.Context, accessToken, proxyURL string) (*DriveStorageInfo, error) } -type driveClient struct { - httpClient *http.Client -} +type driveClient struct{} // NewDriveClient creates a new Drive API client func NewDriveClient() DriveClient { - return &driveClient{ - httpClient: &http.Client{ - Timeout: 10 * time.Second, - }, - } + return &driveClient{} } // GetStorageQuota fetches storage quota from Google Drive API @@ -71,7 +65,7 @@ func (c *driveClient) GetStorageQuota(ctx context.Context, accessToken, proxyURL // Rate limit - retry with exponential backoff if resp.StatusCode == http.StatusTooManyRequests && attempt < maxRetries-1 { - resp.Body.Close() + _ = resp.Body.Close() backoff := time.Duration(1< 24 hours) needsRefresh := true if account.Extra != nil {