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

fix: webdav access and doc event #85

Merged
merged 1 commit into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/apps/apis/webdav/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 0 additions & 22 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand All @@ -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=
Expand Down
4 changes: 2 additions & 2 deletions pkg/document/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/storage/minio.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
Loading