Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

jsoncs3 mtime fix and ctx pass through #3210

Merged
merged 1 commit into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/unreleased/jsoncs3-mtime-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bugfix: jsoncs3 mtime fix

We now correctly update the mtime to only sync when the file changed on the storage.

https://github.com/cs3org/reva/pull/3210
6 changes: 3 additions & 3 deletions pkg/share/manager/jsoncs3/jsoncs3.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,10 +305,10 @@ func (m *Manager) Share(ctx context.Context, md *provider.ResourceInfo, g *colla
}

// getByID must be called in a lock-controlled block.
func (m *Manager) getByID(id *collaboration.ShareId) (*collaboration.Share, error) {
func (m *Manager) getByID(ctx context.Context, id *collaboration.ShareId) (*collaboration.Share, error) {
storageID, spaceID, _ := shareid.Decode(id.OpaqueId)
// sync cache, maybe our data is outdated
err := m.Cache.Sync(context.Background(), storageID, spaceID)
err := m.Cache.Sync(ctx, storageID, spaceID)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -340,7 +340,7 @@ func (m *Manager) getByKey(ctx context.Context, key *collaboration.ShareKey) (*c
func (m *Manager) get(ctx context.Context, ref *collaboration.ShareReference) (s *collaboration.Share, err error) {
switch {
case ref.GetId() != nil:
s, err = m.getByID(ref.GetId())
s, err = m.getByID(ctx, ref.GetId())
case ref.GetKey() != nil:
s, err = m.getByKey(ctx, ref.GetKey())
default:
Expand Down
1 change: 1 addition & 0 deletions pkg/share/manager/jsoncs3/providercache/providercache.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ func (c *Cache) Sync(ctx context.Context, storageID, spaceID string) error {
log.Error().Err(err).Msg("Failed to unmarshal the provider cache")
return err
}
newShares.Mtime = utils.TSToTime(info.Mtime)
c.initializeIfNeeded(storageID, spaceID)
c.Providers[storageID].Spaces[spaceID] = newShares
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (c *Cache) Sync(ctx context.Context, userID string) error {
log.Error().Err(err).Msg("Failed to unmarshal the received share")
return err
}
newSpaces.Mtime = utils.TSToTime(info.Mtime)
c.ReceivedSpaces[userID] = newSpaces
}
log.Debug().Msg("Received share cache is up to date")
Expand Down
1 change: 1 addition & 0 deletions pkg/share/manager/jsoncs3/sharecache/sharecache.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ func (c *Cache) Sync(ctx context.Context, userID string) error {
log.Error().Err(err).Msg("Failed to unmarshal the share cache")
return err
}
newShareCache.Mtime = utils.TSToTime(info.Mtime)
c.UserShares[userID] = newShareCache
}
log.Debug().Msg("Share cache is up to date")
Expand Down