Skip to content

Commit

Permalink
Merge pull request #689 from GoogleCloudPlatform/fixstat
Browse files Browse the repository at this point in the history
Making callers pass forceFetchFromGcs param to clobbered method
  • Loading branch information
Avi committed Jun 20, 2022
2 parents 7802873 + 0b2bb76 commit 27c5c2e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions internal/fs/inode/file.go
Expand Up @@ -153,12 +153,12 @@ func (f *FileInode) checkInvariants() {
}

// LOCKS_REQUIRED(f.mu)
func (f *FileInode) clobbered(ctx context.Context) (o *gcs.Object, b bool, err error) {
func (f *FileInode) clobbered(ctx context.Context, forceFetchFromGcs bool) (o *gcs.Object, b bool, err error) {
// Stat the object in GCS. ForceFetchFromGcs ensures object is fetched from
// gcs and not cache.
req := &gcs.StatObjectRequest{
Name: f.name.GcsObjectName(),
ForceFetchFromGcs: true,
ForceFetchFromGcs: forceFetchFromGcs,
}
o, err = f.bucket.StatObject(ctx, req)

Expand Down Expand Up @@ -371,7 +371,7 @@ func (f *FileInode) Attributes(

// If the object has been clobbered, we reflect that as the inode being
// unlinked.
_, clobbered, err := f.clobbered(ctx)
_, clobbered, err := f.clobbered(ctx, false)
if err != nil {
err = fmt.Errorf("clobbered: %w", err)
return
Expand Down Expand Up @@ -529,7 +529,7 @@ func (f *FileInode) Sync(ctx context.Context) (err error) {
// properties and using that when object is synced below. StatObject by
// default sets the projection to full, which fetches all the object
// properties.
latestGcsObj, isClobbered, err := f.clobbered(ctx)
latestGcsObj, isClobbered, err := f.clobbered(ctx, true)

// Clobbered is treated as being unlinked. There's no reason to return an
// error in that case. We simply return without syncing the object.
Expand Down

0 comments on commit 27c5c2e

Please sign in to comment.