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

Method CheckAndMountAll

service/storage.go:66–99  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

64 return nil
65}
66func (s *storageStruct) CheckAndMountAll() error {
67 storages, err := MyService.Storage().GetStorages()
68 if err != nil {
69 return err
70 }
71 logger.Info("when CheckAndMountAll storages", zap.Any("storages", storages))
72 section, err := httper.GetAllConfigName()
73 if err != nil {
74 return err
75 }
76 logger.Info("when CheckAndMountAll section", zap.Any("section", section))
77 for _, v := range section.Remotes {
78 currentRemote, _ := httper.GetConfigByName(v)
79 mountPoint := currentRemote["mount_point"]
80 if len(mountPoint) == 0 {
81 continue
82 }
83 isMount := false
84 for _, v := range storages.MountPoints {
85 if v.MountPoint == mountPoint {
86 isMount = true
87 break
88 }
89 }
90 if !isMount {
91 logger.Info("when CheckAndMountAll MountStorage", zap.String("mountPoint", mountPoint), zap.String("fs", v))
92 err := MyService.Storage().MountStorage(mountPoint, v+":")
93 if err != nil {
94 logger.Error("when CheckAndMountAll then", zap.String("mountPoint", mountPoint), zap.String("fs", v), zap.Error(err))
95 }
96 }
97 }
98 return nil
99}
100
101func (s *storageStruct) GetConfigByName(name string) (map[string]string, error) {
102 return httper.GetConfigByName(name)

Callers

nothing calls this directly

Calls 7

GetAllConfigNameFunction · 0.92
GetConfigByNameFunction · 0.92
InfoMethod · 0.80
GetStoragesMethod · 0.65
StorageMethod · 0.65
MountStorageMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected