bump reva

Signed-off-by: jkoberg <jkoberg@owncloud.com>
This commit is contained in:
jkoberg
2023-10-27 16:28:31 +02:00
parent 711c86ef3a
commit 860afc0049
7 changed files with 33 additions and 37 deletions

View File

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

View File

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

View File

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