Add buckets caching to GcsFS

Without it each files interaction on GCS results in an unnecessary
GetBucket request.
This commit is contained in:
mike.art 2024-04-29 15:38:10 +02:00
parent 5c4385aa20
commit 822ef76948
1 changed files with 2 additions and 0 deletions

View File

@ -54,6 +54,7 @@ func NewGcsFsWithSeparator(ctx context.Context, client stiface.Client, folderSep
ctx: ctx, ctx: ctx,
client: client, client: client,
separator: folderSep, separator: folderSep,
buckets: make(map[string]stiface.BucketHandle),
rawGcsObjects: make(map[string]*GcsFile), rawGcsObjects: make(map[string]*GcsFile),
autoRemoveEmptyFolders: true, autoRemoveEmptyFolders: true,
@ -109,6 +110,7 @@ func (fs *Fs) getBucket(name string) (stiface.BucketHandle, error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
fs.buckets[name] = bucket
} }
return bucket, nil return bucket, nil
} }