@@ -131,13 +131,12 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
131
131
}
132
132
ref := spacelookup .MakeRelativeReference (space , "." , false )
133
133
134
- // key will be a base64 encoded cs3 path, it uniquely identifies a trash item & storage
135
- var key string
136
- key , r .URL .Path = router .ShiftPath (r .URL .Path )
134
+ // key will be a base64 encoded cs3 path, it uniquely identifies a trash item with an opaque id and an optional path
135
+ key := r .URL .Path
137
136
138
137
switch r .Method {
139
138
case MethodPropfind :
140
- h .listTrashbin (w , r , s , ref , user .Username , key , r . URL . Path )
139
+ h .listTrashbin (w , r , s , ref , user .Username , key )
141
140
case MethodMove :
142
141
if key == "" {
143
142
http .Error (w , "501 Not implemented" , http .StatusNotImplemented )
@@ -172,16 +171,16 @@ func (h *TrashbinHandler) Handler(s *svc) http.Handler {
172
171
dstRef := spacelookup .MakeRelativeReference (space , p , false )
173
172
174
173
log .Debug ().Str ("key" , key ).Str ("dst" , dst ).Msg ("restore" )
175
- h .restore (w , r , s , ref , dstRef , key , r . URL . Path )
174
+ h .restore (w , r , s , ref , dstRef , key )
176
175
case http .MethodDelete :
177
- h .delete (w , r , s , ref , key , r . URL . Path )
176
+ h .delete (w , r , s , ref , key )
178
177
default :
179
178
http .Error (w , "501 Not implemented" , http .StatusNotImplemented )
180
179
}
181
180
})
182
181
}
183
182
184
- func (h * TrashbinHandler ) listTrashbin (w http.ResponseWriter , r * http.Request , s * svc , ref * provider.Reference , refBase , key , itemPath string ) {
183
+ func (h * TrashbinHandler ) listTrashbin (w http.ResponseWriter , r * http.Request , s * svc , ref * provider.Reference , refBase , key string ) {
185
184
ctx , span := appctx .GetTracerProvider (r .Context ()).Tracer (tracerName ).Start (r .Context (), "list_trashbin" )
186
185
defer span .End ()
187
186
@@ -214,7 +213,7 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
214
213
}
215
214
216
215
if depth == net .DepthZero {
217
- rootHref := path .Join (refBase , key , itemPath )
216
+ rootHref := path .Join (refBase , key )
218
217
propRes , err := h .formatTrashPropfind (ctx , s , ref .ResourceId .SpaceId , refBase , rootHref , nil , nil )
219
218
if err != nil {
220
219
sublog .Error ().Err (err ).Msg ("error formatting propfind" )
@@ -246,7 +245,7 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
246
245
return
247
246
}
248
247
// ask gateway for recycle items
249
- getRecycleRes , err := client .ListRecycle (ctx , & provider.ListRecycleRequest {Ref : ref , Key : path . Join ( key , itemPath ) })
248
+ getRecycleRes , err := client .ListRecycle (ctx , & provider.ListRecycleRequest {Ref : ref , Key : key })
250
249
if err != nil {
251
250
sublog .Error ().Err (err ).Msg ("error calling ListRecycle" )
252
251
w .WriteHeader (http .StatusInternalServerError )
@@ -304,7 +303,7 @@ func (h *TrashbinHandler) listTrashbin(w http.ResponseWriter, r *http.Request, s
304
303
}
305
304
}
306
305
307
- rootHref := path .Join (refBase , key , itemPath )
306
+ rootHref := path .Join (refBase , key )
308
307
propRes , err := h .formatTrashPropfind (ctx , s , ref .ResourceId .SpaceId , refBase , rootHref , & pf , items )
309
308
if err != nil {
310
309
sublog .Error ().Err (err ).Msg ("error formatting propfind" )
@@ -480,7 +479,7 @@ func (h *TrashbinHandler) itemToPropResponse(ctx context.Context, s *svc, spaceI
480
479
return & response , nil
481
480
}
482
481
483
- func (h * TrashbinHandler ) restore (w http.ResponseWriter , r * http.Request , s * svc , ref , dst * provider.Reference , key , itemPath string ) {
482
+ func (h * TrashbinHandler ) restore (w http.ResponseWriter , r * http.Request , s * svc , ref , dst * provider.Reference , key string ) {
484
483
ctx , span := appctx .GetTracerProvider (r .Context ()).Tracer (tracerName ).Start (r .Context (), "restore" )
485
484
defer span .End ()
486
485
@@ -566,7 +565,7 @@ func (h *TrashbinHandler) restore(w http.ResponseWriter, r *http.Request, s *svc
566
565
567
566
req := & provider.RestoreRecycleItemRequest {
568
567
Ref : ref ,
569
- Key : path . Join ( key , itemPath ) ,
568
+ Key : key ,
570
569
RestoreRef : dst ,
571
570
}
572
571
@@ -608,16 +607,15 @@ func (h *TrashbinHandler) restore(w http.ResponseWriter, r *http.Request, s *svc
608
607
}
609
608
610
609
// delete has only a key
611
- func (h * TrashbinHandler ) delete (w http.ResponseWriter , r * http.Request , s * svc , ref * provider.Reference , key , itemPath string ) {
610
+ func (h * TrashbinHandler ) delete (w http.ResponseWriter , r * http.Request , s * svc , ref * provider.Reference , key string ) {
612
611
ctx , span := appctx .GetTracerProvider (r .Context ()).Tracer (tracerName ).Start (r .Context (), "erase" )
613
612
defer span .End ()
614
613
615
- sublog := appctx .GetLogger (ctx ).With ().Interface ("reference" , ref ).Str ("key" , key ).Str ( "item_path" , itemPath ). Logger ()
614
+ sublog := appctx .GetLogger (ctx ).With ().Interface ("reference" , ref ).Str ("key" , key ).Logger ()
616
615
617
- trashPath := path .Join (key , itemPath )
618
616
req := & provider.PurgeRecycleRequest {
619
617
Ref : ref ,
620
- Key : trashPath ,
618
+ Key : key ,
621
619
}
622
620
623
621
client , err := s .gatewaySelector .Next ()
@@ -638,7 +636,7 @@ func (h *TrashbinHandler) delete(w http.ResponseWriter, r *http.Request, s *svc,
638
636
case rpc .Code_CODE_NOT_FOUND :
639
637
sublog .Debug ().Interface ("status" , res .Status ).Msg ("resource not found" )
640
638
w .WriteHeader (http .StatusConflict )
641
- m := fmt .Sprintf ("path %s not found" , trashPath )
639
+ m := fmt .Sprintf ("key %s not found" , key )
642
640
b , err := errors .Marshal (http .StatusConflict , m , "" , "" )
643
641
errors .HandleWebdavError (& sublog , w , b , err )
644
642
case rpc .Code_CODE_PERMISSION_DENIED :
0 commit comments