Skip to content

Commit

Permalink
check if attribute was already set only for SetLock
Browse files Browse the repository at this point in the history
  • Loading branch information
gmgigi96 committed Apr 20, 2022
1 parent 654c717 commit 2af96ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ func (fs *eosfs) GetLock(ctx context.Context, ref *provider.Reference) (*provide
return fs.getLock(ctx, auth, user, path, ref)
}

func (fs *eosfs) setLock(ctx context.Context, auth eosclient.Authorization, lock *provider.Lock, path string) error {
func (fs *eosfs) setLock(ctx context.Context, auth eosclient.Authorization, lock *provider.Lock, path string, check bool) error {
encodedLock, err := encodeLock(lock)
if err != nil {
return errors.Wrap(err, "eosfs: error encoding lock")
Expand All @@ -725,7 +725,7 @@ func (fs *eosfs) setLock(ctx context.Context, auth eosclient.Authorization, lock
Type: SystemAttr,
Key: LockExpirationKey,
Val: strconv.FormatUint(lock.Expiration.Seconds, 10),
}, true, false, path)
}, check, false, path)
switch {
case errors.Is(err, eosclient.AttrAlreadyExistsError):
return errtypes.BadRequest("lock already set")
Expand Down Expand Up @@ -813,7 +813,7 @@ func (fs *eosfs) SetLock(ctx context.Context, ref *provider.Reference, l *provid
}
}

return fs.setLock(ctx, auth, l, path)
return fs.setLock(ctx, auth, l, path, true)
}

func (fs *eosfs) getUserFromID(ctx context.Context, userID *userpb.UserId) (*userpb.User, error) {
Expand Down Expand Up @@ -932,7 +932,7 @@ func (fs *eosfs) RefreshLock(ctx context.Context, ref *provider.Reference, newLo
return errors.Wrap(err, "eosfs: error getting uid and gid for user")
}

return fs.setLock(ctx, auth, newLock, path)
return fs.setLock(ctx, auth, newLock, path, false)
}

func sameHolder(l1, l2 *provider.Lock) bool {
Expand Down

0 comments on commit 2af96ed

Please sign in to comment.