(c *gin.Context)
| 250 | } |
| 251 | |
| 252 | func SharingArchiveExtract(c *gin.Context) { |
| 253 | if !setting.GetBool(conf.ShareArchivePreview) { |
| 254 | common.ErrorPage(c, errors.New("sharing archives previewing is not allowed"), 403) |
| 255 | return |
| 256 | } |
| 257 | sid := c.Request.Context().Value(conf.SharingIDKey).(string) |
| 258 | path := c.Request.Context().Value(conf.PathKey).(string) |
| 259 | path = utils.FixAndCleanPath(path) |
| 260 | pwd := c.Query("pwd") |
| 261 | innerPath := utils.FixAndCleanPath(c.Query("inner")) |
| 262 | archivePass := c.Query("pass") |
| 263 | s, err := op.GetSharingById(sid) |
| 264 | if err == nil { |
| 265 | if !s.Valid() { |
| 266 | err = errs.InvalidSharing |
| 267 | } else if !s.Verify(pwd) { |
| 268 | err = errs.WrongShareCode |
| 269 | } else if len(s.Files) != 1 && path == "/" { |
| 270 | err = errors.New("cannot extract sharing root") |
| 271 | } |
| 272 | } |
| 273 | if dealErrorPage(c, err) { |
| 274 | return |
| 275 | } |
| 276 | unwrapPath, err := op.GetSharingUnwrapPath(s, path) |
| 277 | if err != nil { |
| 278 | common.ErrorPage(c, errors.New("failed get sharing unwrap path"), 500) |
| 279 | return |
| 280 | } |
| 281 | storage, actualPath, err := op.GetStorageAndActualPath(unwrapPath) |
| 282 | if dealErrorPage(c, err) { |
| 283 | return |
| 284 | } |
| 285 | args := model.ArchiveInnerArgs{ |
| 286 | ArchiveArgs: model.ArchiveArgs{ |
| 287 | LinkArgs: model.LinkArgs{ |
| 288 | Header: c.Request.Header, |
| 289 | Type: c.Query("type"), |
| 290 | }, |
| 291 | Password: archivePass, |
| 292 | }, |
| 293 | InnerPath: innerPath, |
| 294 | } |
| 295 | if _, ok := storage.(driver.ArchiveReader); ok { |
| 296 | if setting.GetBool(conf.ShareForceProxy) || common.ShouldProxy(storage, stdpath.Base(actualPath)) { |
| 297 | link, obj, err := op.DriverExtract(c.Request.Context(), storage, actualPath, args) |
| 298 | if dealErrorPage(c, err) { |
| 299 | return |
| 300 | } |
| 301 | proxy(c, link, obj, storage.GetStorage().ProxyRange) |
| 302 | } else { |
| 303 | args.Redirect = true |
| 304 | link, _, err := op.DriverExtract(c.Request.Context(), storage, actualPath, args) |
| 305 | if dealErrorPage(c, err) { |
| 306 | return |
| 307 | } |
| 308 | redirect(c, link) |
| 309 | } |
nothing calls this directly
no test coverage detected