mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
9
vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/locks.go
generated
vendored
9
vendor/github.com/cs3org/reva/v2/internal/http/services/owncloud/ocdav/locks.go
generated
vendored
@@ -506,10 +506,15 @@ func (s *svc) lockReference(ctx context.Context, w http.ResponseWriter, r *http.
|
||||
// this actually is a name based lock ... ugh
|
||||
token, err = s.LockSystem.Create(ctx, now, ld)
|
||||
if err != nil {
|
||||
if _, ok := err.(errtypes.Aborted); ok {
|
||||
switch err.(type) {
|
||||
case errtypes.Aborted:
|
||||
return http.StatusLocked, err
|
||||
case errtypes.PermissionDenied:
|
||||
return http.StatusForbidden, err
|
||||
default:
|
||||
return http.StatusInternalServerError, err
|
||||
|
||||
}
|
||||
return http.StatusInternalServerError, err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
|
||||
@@ -88,6 +88,7 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
} else {
|
||||
if s.State == collaboration.ShareState_SHARE_STATE_ACCEPTED {
|
||||
s.Hidden = h.getReceivedShareHideFlagFromShareID(r.Context(), shareID)
|
||||
mountedShares = append(mountedShares, s)
|
||||
}
|
||||
}
|
||||
@@ -127,7 +128,8 @@ func (h *Handler) AcceptReceivedShare(w http.ResponseWriter, r *http.Request) {
|
||||
Share: &collaboration.Share{
|
||||
Id: &collaboration.ShareId{OpaqueId: shareID},
|
||||
},
|
||||
State: collaboration.ShareState_SHARE_STATE_ACCEPTED,
|
||||
State: collaboration.ShareState_SHARE_STATE_ACCEPTED,
|
||||
Hidden: h.getReceivedShareHideFlagFromShareID(r.Context(), shareID),
|
||||
MountPoint: &provider.Reference{
|
||||
Path: mount,
|
||||
},
|
||||
@@ -151,7 +153,8 @@ func (h *Handler) RejectReceivedShare(w http.ResponseWriter, r *http.Request) {
|
||||
Share: &collaboration.Share{
|
||||
Id: &collaboration.ShareId{OpaqueId: shareID},
|
||||
},
|
||||
State: collaboration.ShareState_SHARE_STATE_REJECTED,
|
||||
State: collaboration.ShareState_SHARE_STATE_REJECTED,
|
||||
Hidden: h.getReceivedShareHideFlagFromShareID(r.Context(), shareID),
|
||||
}
|
||||
updateMask := &fieldmaskpb.FieldMask{Paths: []string{"state", "hidden"}}
|
||||
|
||||
@@ -238,7 +241,7 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, re
|
||||
}
|
||||
|
||||
data.State = mapState(rs.GetState())
|
||||
data.Hidden = rs.Hidden
|
||||
data.Hidden = rs.GetHidden()
|
||||
|
||||
h.addFileInfo(ctx, data, info)
|
||||
h.mapUserIds(r.Context(), client, data)
|
||||
@@ -251,6 +254,19 @@ func (h *Handler) updateReceivedShare(w http.ResponseWriter, r *http.Request, re
|
||||
return data
|
||||
}
|
||||
|
||||
// getReceivedShareHideFlagFromShareId returns the hide flag of a received share based on its ID.
|
||||
func (h *Handler) getReceivedShareHideFlagFromShareID(ctx context.Context, shareID string) bool {
|
||||
client, err := h.getClient()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
rs, _ := getReceivedShareFromID(ctx, client, shareID)
|
||||
if rs != nil {
|
||||
return rs.GetShare().GetHidden()
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// getReceivedShareFromID uses a client to the gateway to fetch a share based on its ID.
|
||||
func getReceivedShareFromID(ctx context.Context, client gateway.GatewayAPIClient, shareID string) (*collaboration.GetReceivedShareResponse, *response.Response) {
|
||||
s, err := client.GetReceivedShare(ctx, &collaboration.GetReceivedShareRequest{
|
||||
|
||||
30
vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/locks.go
generated
vendored
30
vendor/github.com/cs3org/reva/v2/pkg/storage/utils/decomposedfs/node/locks.go
generated
vendored
@@ -276,38 +276,12 @@ func (n *Node) CheckLock(ctx context.Context) error {
|
||||
}
|
||||
|
||||
func readLocksIntoOpaque(ctx context.Context, n *Node, ri *provider.ResourceInfo) error {
|
||||
|
||||
// ensure parent path exists
|
||||
if err := os.MkdirAll(filepath.Dir(n.InternalPath()), 0700); err != nil {
|
||||
return errors.Wrap(err, "Decomposedfs: error creating parent folder for lock")
|
||||
}
|
||||
fileLock, err := filelocks.AcquireReadLock(n.InternalPath())
|
||||
|
||||
lock, err := n.ReadLock(ctx, false)
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Msg("Decomposedfs: could not read lock")
|
||||
return err
|
||||
}
|
||||
|
||||
defer func() {
|
||||
rerr := filelocks.ReleaseLock(fileLock)
|
||||
|
||||
// if err is non nil we do not overwrite that
|
||||
if err == nil {
|
||||
err = rerr
|
||||
}
|
||||
}()
|
||||
|
||||
f, err := os.Open(n.LockFilePath())
|
||||
if err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Msg("Decomposedfs: could not open lock file")
|
||||
return err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
lock := &provider.Lock{}
|
||||
if err := json.NewDecoder(f).Decode(lock); err != nil {
|
||||
appctx.GetLogger(ctx).Error().Err(err).Msg("Decomposedfs: could not read lock file")
|
||||
}
|
||||
|
||||
// reencode to ensure valid json
|
||||
var b []byte
|
||||
if b, err = json.Marshal(lock); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user