Skip to content

Commit

Permalink
bugfix(list): fix listing on s3
Browse files Browse the repository at this point in the history
  • Loading branch information
aldor007 committed Jan 24, 2019
1 parent ed752ca commit 3d14dd2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions go.mod
Expand Up @@ -2,6 +2,7 @@ module github.com/Aldor007/mort

require (
github.com/aldor007/go-aws-auth v0.0.0-20180623204207-00898dfb9272
github.com/aldor007/mort v0.12.0
github.com/aldor007/stow v0.0.0-20190109171535-d59ae5fea5cf
github.com/aws/aws-sdk-go v1.16.14
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973
Expand All @@ -11,6 +12,7 @@ require (
github.com/go-chi/chi v3.3.3+incompatible
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
github.com/golang/protobuf v1.2.0
github.com/google/brotli v1.0.7
github.com/google/readahead v0.0.0-20161222183148-eaceba169032
github.com/graymeta/stow v0.0.0-20181228161447-b469cfb112f8
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af
Expand Down
15 changes: 14 additions & 1 deletion pkg/storage/storage.go
Expand Up @@ -84,6 +84,7 @@ func Head(obj *object.FileObject) *response.Response {
item, err := client.Item(key)
if err != nil {
if err == stow.ErrNotFound {

monitoring.Log().Info("Storage/Head item response", obj.LogData(zap.Int("sc", 404))...)
return response.NewString(404, notFound)
}
Expand All @@ -106,6 +107,16 @@ func Set(obj *object.FileObject, metaHeaders http.Header, contentLen int64, body
return response.NewError(503, err)
}

key := getKey(obj)
switch obj.Storage.Kind {
case "s3":
// in such case we want to create dir but s3 is key/value store so it is not handling it
if contentLen == 0 && strings.HasSuffix(key, "/") {
res := response.NewNoContent(200)
return res
}

}
_, err = client.Put(getKey(obj), body, contentLen, prepareMetadata(obj, metaHeaders))

if err != nil {
Expand Down Expand Up @@ -154,7 +165,9 @@ func List(obj *object.FileObject, maxKeys int, _ string, prefix string, marker s
return response.NewError(503, err)
}

if prefix != "" && prefix != "/" {
prefix = path.Join(obj.Storage.PathPrefix, prefix)

if prefix != "" && prefix != "/" && obj.Storage.Kind == "local-meta" {
_, err = client.Item(prefix)
if err != nil {
if err == stow.ErrNotFound {
Expand Down

0 comments on commit 3d14dd2

Please sign in to comment.