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

Delete object doesn't check conditions #1282

Open
yvrhdn opened this issue Aug 7, 2023 · 1 comment
Open

Delete object doesn't check conditions #1282

yvrhdn opened this issue Aug 7, 2023 · 1 comment

Comments

@yvrhdn
Copy link

yvrhdn commented Aug 7, 2023

Hi, thanks for this project, it's been really helpful for us!

I noticed that conditions are not checked when you delete an object. When we create or update objects conditions work as expected.

I'm sending a request with an invalid version 123:

DELETE /storage/v1/b/tempo/o/overrides%2Fsingle-tenant%2Foverrides.json?alt=json&ifGenerationMatch=123&prettyPrint=false

This request should fail but it succeeds with a 200 and deletes the object.


Digging through the code it seems storageFS.DeleteObject does not pass in conditions:

// DeleteObject deletes an object by bucket and name.
func (s *storageFS) DeleteObject(bucketName, objectName string) error {
s.mtx.Lock()
defer s.mtx.Unlock()
if objectName == "" {
return errors.New("can't delete object with empty name")
}
path := filepath.Join(s.rootDir, url.PathEscape(bucketName), objectName)
if err := s.mh.remove(path); err != nil {
return err
}
return os.Remove(path)
}

Would the solution be as simple as passing in the Conditions and checking them like you do in CreateObject?

func (s *storageFS) CreateObject(obj StreamingObject, conditions Conditions) (StreamingObject, error) {

@noamshvacher
Copy link

@fsouza Hi, are there any updates on that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants