MCPcopy
hub / github.com/IceWhaleTech/CasaOS / ListStorages

Function ListStorages

route/v1/cloud.go:18–48  ·  view source on GitHub ↗
(ctx echo.Context)

Source from the content-addressed store, hash-verified

16)
17
18func ListStorages(ctx echo.Context) error {
19 r, err := service.MyService.Storage().GetStorages()
20 if err != nil {
21 return ctx.JSON(common_err.SUCCESS, model.Result{Success: common_err.SERVICE_ERROR, Message: common_err.GetMsg(common_err.SERVICE_ERROR), Data: err.Error()})
22 }
23
24 for i := 0; i < len(r.MountPoints); i++ {
25 dataMap, err := service.MyService.Storage().GetConfigByName(r.MountPoints[i].Fs)
26 if err != nil {
27 logger.Error("GetConfigByName", zap.Any("err", err))
28 continue
29 }
30 if dataMap["type"] == "drive" {
31 r.MountPoints[i].Icon = google_drive.ICONURL
32 }
33 if dataMap["type"] == "dropbox" {
34 r.MountPoints[i].Icon = dropbox.ICONURL
35 }
36 if dataMap["type"] == "onedrive" {
37 r.MountPoints[i].Icon = onedrive.ICONURL
38 }
39 r.MountPoints[i].Name = dataMap["username"]
40 }
41 list := []httper.MountPoint{}
42
43 for _, v := range r.MountPoints {
44 list = append(list, httper.MountPoint(v))
45 }
46
47 return ctx.JSON(common_err.SUCCESS, model.Result{Success: common_err.SUCCESS, Message: common_err.GetMsg(common_err.SUCCESS), Data: list})
48}
49
50func UmountStorage(ctx echo.Context) error {
51 json := make(map[string]string)

Callers

nothing calls this directly

Calls 6

GetMsgFunction · 0.92
MountPointStruct · 0.92
GetStoragesMethod · 0.65
StorageMethod · 0.65
GetConfigByNameMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected