MCPcopy Create free account
hub / github.com/OpenSN-Library/OpenSN-Library / DeleteFileHandler

Function DeleteFileHandler

daemon/pkg/handler/file_handler.go:149–170  ·  view source on GitHub ↗
(ctx *gin.Context)

Source from the content-addressed store, hash-verified

147}
148
149func DeleteFileHandler(ctx *gin.Context) {
150 relativePath := ctx.Query("path")
151 removePath := path.Join(dir.UserDataDir, relativePath)
152 err := os.RemoveAll(removePath)
153 if err != nil {
154 errMsg := fmt.Sprintf("Remove %s Error: %s", removePath, err.Error())
155 logrus.Errorf(errMsg)
156 resp := ginmodel.JsonResp{
157 Code: -1,
158 Message: errMsg,
159 Data: nil,
160 }
161 ctx.JSON(http.StatusInternalServerError, resp)
162 return
163 }
164 resp := ginmodel.JsonResp{
165 Code: 0,
166 Message: "success",
167 Data: nil,
168 }
169 ctx.JSON(http.StatusOK, resp)
170}
171
172func DownloadFileHandler(ctx *gin.Context) {
173 relativePath := ctx.Query("path")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected