fsouza / fake-gcs-server

Google Cloud Storage emulator & testing library.

Home Page:https://pkg.go.dev/github.com/fsouza/fake-gcs-server/fakestorage?tab=doc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delete object doesn't check conditions

kvrhdn opened this issue · comments

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) {

@fsouza Hi, are there any updates on that?