MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / SharingArchiveMeta

Function SharingArchiveMeta

server/handles/sharing.go:107–148  ·  view source on GitHub ↗
(c *gin.Context, req *ArchiveMetaReq)

Source from the content-addressed store, hash-verified

105}
106
107func SharingArchiveMeta(c *gin.Context, req *ArchiveMetaReq) {
108 if !setting.GetBool(conf.ShareArchivePreview) {
109 common.ErrorStrResp(c, "sharing archives previewing is not allowed", 403)
110 return
111 }
112 sid, path, _ := strings.Cut(strings.TrimPrefix(req.Path, "/"), "/")
113 if sid == "" {
114 common.ErrorStrResp(c, "invalid share id", 400)
115 return
116 }
117 archiveArgs := model.ArchiveArgs{
118 LinkArgs: model.LinkArgs{
119 Header: c.Request.Header,
120 Type: c.Query("type"),
121 },
122 Password: req.ArchivePass,
123 }
124 s, ret, err := sharing.ArchiveMeta(c.Request.Context(), sid, path, model.SharingArchiveMetaArgs{
125 ArchiveMetaArgs: model.ArchiveMetaArgs{
126 ArchiveArgs: archiveArgs,
127 Refresh: req.Refresh,
128 },
129 Pwd: req.Password,
130 })
131 if dealError(c, err) {
132 return
133 }
134 _ = countAccess(c.ClientIP(), s)
135 fakePath := fmt.Sprintf("/%s/%s", sid, path)
136 url := fmt.Sprintf("%s/sad%s", common.GetApiUrl(c), utils.EncodePath(fakePath, true))
137 if s.Pwd != "" {
138 url += "?pwd=" + s.Pwd
139 }
140 common.SuccessResp(c, ArchiveMetaResp{
141 Comment: ret.GetComment(),
142 IsEncrypted: ret.IsEncrypted(),
143 Content: toContentResp(ret.GetTree()),
144 Sort: ret.Sort,
145 RawURL: url,
146 Sign: "",
147 })
148}
149
150func SharingArchiveList(c *gin.Context, req *ArchiveListReq) {
151 if !setting.GetBool(conf.ShareArchivePreview) {

Callers 1

FsArchiveMetaSplitFunction · 0.85

Calls 12

GetBoolFunction · 0.92
ErrorStrRespFunction · 0.92
ArchiveMetaFunction · 0.92
GetApiUrlFunction · 0.92
EncodePathFunction · 0.92
SuccessRespFunction · 0.92
dealErrorFunction · 0.85
countAccessFunction · 0.85
toContentRespFunction · 0.85
GetCommentMethod · 0.65
IsEncryptedMethod · 0.65
GetTreeMethod · 0.65

Tested by

no test coverage detected