diff --git a/cmd/apps/apis/webdav/utils.go b/cmd/apps/apis/webdav/utils.go index f06f764a..088ed25d 100644 --- a/cmd/apps/apis/webdav/utils.go +++ b/cmd/apps/apis/webdav/utils.go @@ -36,7 +36,8 @@ func Stat(entry *types.Metadata) Info { func mode2EntryAttr(mode os.FileMode) types.EntryAttr { attr := types.EntryAttr{ - Kind: fileKindFromMode(uint32(mode)), + Kind: fileKindFromMode(uint32(mode)), + Access: &types.Access{}, } dentry.UpdateAccessWithMode(attr.Access, uint32(mode)) return attr diff --git a/go.sum b/go.sum index 31c89a24..788aa74a 100644 --- a/go.sum +++ b/go.sum @@ -45,20 +45,6 @@ github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aws/smithy-go v1.13.5/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk= github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= -github.com/basenana/friday v0.0.0-20231120122025-89234e922aef h1:8F6Z3n21MtoAqczk86GRhRNv58UjAp4g6TonrLV661c= -github.com/basenana/friday v0.0.0-20231120122025-89234e922aef/go.mod h1:4mg3pqSO8IItXCZvKQs/04CaIT6Oj47u4zddixWqqIA= -github.com/basenana/friday v0.0.0-20231203071226-7c2a7da058a1 h1:FXfnwa7631c+ODPX9/n21ofwfRK+j7tW4rc2PSRe8r8= -github.com/basenana/friday v0.0.0-20231203071226-7c2a7da058a1/go.mod h1:l0m9tX7pY7jGmCVBDwy66qr5UOBrSZVSfJnq7j6prEk= -github.com/basenana/friday v0.0.0-20231204151222-72e7fc3de07f h1:5jjQtAuY4Ld8mr93Z0Gsv9rIqlG5QkRX4x8BLdqDL5o= -github.com/basenana/friday v0.0.0-20231204151222-72e7fc3de07f/go.mod h1:l0m9tX7pY7jGmCVBDwy66qr5UOBrSZVSfJnq7j6prEk= -github.com/basenana/friday v0.0.0-20231205133028-564ca738d5c3 h1:+ygnCHQtcKsDacPfUCCh7R1DTu9MeR36EvvQP/eQtkI= -github.com/basenana/friday v0.0.0-20231205133028-564ca738d5c3/go.mod h1:l0m9tX7pY7jGmCVBDwy66qr5UOBrSZVSfJnq7j6prEk= -github.com/basenana/friday v0.0.0-20231206152142-6b4e0d5b1bef h1:w4OQkYzjInNVdRxaSavxQUik8yPOdwlqsjv1yYDts94= -github.com/basenana/friday v0.0.0-20231206152142-6b4e0d5b1bef/go.mod h1:OGCCDNAXqN/ZTqO8EsaGGUBt5GrVwb/BVdnDQA4KbZI= -github.com/basenana/friday v0.0.0-20231207142041-8f7eb86afc78 h1:PPj10ZL8OUIzT2wciS1RPA9Ayl6J6X719NV0y+gTCV0= -github.com/basenana/friday v0.0.0-20231207142041-8f7eb86afc78/go.mod h1:OGCCDNAXqN/ZTqO8EsaGGUBt5GrVwb/BVdnDQA4KbZI= -github.com/basenana/friday v0.0.0-20231209065908-7ba12e67f748 h1:STmXI0Q6G3P55zZJRpkgJKQrcyb3/bTgKD/f2QJSU2Y= -github.com/basenana/friday v0.0.0-20231209065908-7ba12e67f748/go.mod h1:OGCCDNAXqN/ZTqO8EsaGGUBt5GrVwb/BVdnDQA4KbZI= github.com/basenana/friday v0.0.0-20231216063336-c2c9735897d8 h1:jGuzKXoNJ4lIHe/SJmCfMZWSmo3DdDu7evZWNmxXkcs= github.com/basenana/friday v0.0.0-20231216063336-c2c9735897d8/go.mod h1:OGCCDNAXqN/ZTqO8EsaGGUBt5GrVwb/BVdnDQA4KbZI= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= @@ -143,7 +129,6 @@ github.com/glebarez/sqlite v1.7.0/go.mod h1:PkeevrRlF/1BhQBCnzcMWzgrIk7IOop+qS2j github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-gormigrate/gormigrate/v2 v2.1.1 h1:eGS0WTFRV30r103lU8JNXY27KbviRnqqIDobW3EV3iY= github.com/go-gormigrate/gormigrate/v2 v2.1.1/go.mod h1:L7nJ620PFDKei9QOhJzqA8kRCk+E3UbV2f5gv+1ndLc= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= @@ -203,8 +188,6 @@ github.com/hanwen/go-fuse/v2 v2.3.0/go.mod h1:xKwi1cF7nXAOBCXujD5ie0ZKsxc8GGSA1r github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hyponet/eventbus v1.0.0 h1:Cl1v4Ge1/ILn/z4nBhxu1cTny8joRPDj3pqRudlbO+w= github.com/hyponet/eventbus v1.0.0/go.mod h1:5XPvonkyxwwNSMEqnpuSh1NlW3KZKpRr9DNKkZBBuyk= -github.com/hyponet/webpage-packer v0.0.0-20231201131423-f3db639fa08f h1:K7lxhx9xnOYGo68JT93MkJHhKrvvpnlwabDz+TIs4tQ= -github.com/hyponet/webpage-packer v0.0.0-20231201131423-f3db639fa08f/go.mod h1:mmLf2lkCtlNxHWic8fa4iLrzjiZG8x6Qp/PamlJt648= github.com/hyponet/webpage-packer v0.0.0-20231205130517-cacb2331677f h1:4LRlh9HBqsusIEDV4tBmHVurdbdCF8HvSg3l8AO+uFw= github.com/hyponet/webpage-packer v0.0.0-20231205130517-cacb2331677f/go.mod h1:mmLf2lkCtlNxHWic8fa4iLrzjiZG8x6Qp/PamlJt648= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= @@ -222,10 +205,8 @@ github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/klauspost/compress v1.16.0 h1:iULayQNOReoYUe+1qtKOqw9CwJv3aNQu8ivo7lw1HU4= github.com/klauspost/compress v1.16.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= @@ -277,7 +258,6 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mschoch/smat v0.2.0 h1:8imxQsjDm8yFEAVBe7azKmKSgzSkZXDuKkSq9374khM= github.com/mschoch/smat v0.2.0/go.mod h1:kc9mz7DoBKqDyiRL7VZN8KvXQMWeTaVnttLRXOlotKw= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU= @@ -298,7 +278,6 @@ github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFu github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= @@ -321,7 +300,6 @@ github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= -github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/slok/go-http-metrics v0.10.0 h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM= diff --git a/pkg/document/manager.go b/pkg/document/manager.go index e573ca52..a10cdeed 100644 --- a/pkg/document/manager.go +++ b/pkg/document/manager.go @@ -136,7 +136,7 @@ func (m *manager) SaveDocument(ctx context.Context, doc *types.Document) error { m.logger.Errorw("update document failed", "document", crtDoc.ID, "err", err) return err } - m.publicDocActionEvent(events.ActionTypeUpdate, doc) + m.publicDocActionEvent(events.ActionTypeUpdate, crtDoc) return nil } // update @@ -158,7 +158,7 @@ func (m *manager) SaveDocument(ctx context.Context, doc *types.Document) error { m.logger.Errorw("update document failed", "document", doc.ID, "err", err) return err } - m.publicDocActionEvent(events.ActionTypeUpdate, doc) + m.publicDocActionEvent(events.ActionTypeUpdate, crtDoc) return nil } diff --git a/pkg/storage/minio.go b/pkg/storage/minio.go index 8c8cddfc..1f13acc5 100644 --- a/pkg/storage/minio.go +++ b/pkg/storage/minio.go @@ -21,6 +21,7 @@ import ( "context" "fmt" "github.com/basenana/nanafs/config" + "github.com/basenana/nanafs/pkg/types" "github.com/basenana/nanafs/utils" "github.com/basenana/nanafs/utils/logger" "github.com/minio/minio-go/v7" @@ -131,6 +132,9 @@ func (m *minioStorage) Head(ctx context.Context, key int64, idx int64) (Info, er info, err := m.cli.StatObject(ctx, m.bucket, minioObjectName(key, idx), minio.StatObjectOptions{}) if err != nil { m.logger.Errorw("head object failed", "object", minioObjectName(key, idx), "err", err) + if rErr := minio.ToErrorResponse(err); rErr.Code == "NoSuchKey" { + err = types.ErrNotFound + } return Info{}, err } return Info{Key: info.Key, Size: info.Size}, nil