MCPcopy
hub / github.com/wavetermdev/waveterm / MakeDraftFromLocal

Function MakeDraftFromLocal

pkg/waveappstore/waveappstore.go:179–216  ·  view source on GitHub ↗
(localAppId string)

Source from the content-addressed store, hash-verified

177}
178
179func MakeDraftFromLocal(localAppId string) (string, error) {
180 if err := ValidateAppId(localAppId); err != nil {
181 return "", fmt.Errorf("invalid appId: %w", err)
182 }
183
184 appNS, appName, _ := ParseAppId(localAppId)
185 if appNS != AppNSLocal {
186 return "", fmt.Errorf("appId must be in local namespace, got: %s", appNS)
187 }
188
189 localDir, err := GetAppDir(localAppId)
190 if err != nil {
191 return "", err
192 }
193
194 if _, err := os.Stat(localDir); os.IsNotExist(err) {
195 return "", fmt.Errorf("local app does not exist: %s", localDir)
196 }
197
198 draftAppId := MakeAppId(AppNSDraft, appName)
199 draftDir, err := GetAppDir(draftAppId)
200 if err != nil {
201 return "", err
202 }
203
204 if _, err := os.Stat(draftDir); err == nil {
205 // draft already exists, don't overwrite (that's what RevertDraft is for)
206 return draftAppId, nil
207 } else if !os.IsNotExist(err) {
208 return "", err
209 }
210
211 if err := copyDir(localDir, draftDir); err != nil {
212 return "", err
213 }
214
215 return draftAppId, nil
216}
217
218func DeleteApp(appId string) error {
219 if err := ValidateAppId(appId); err != nil {

Callers 1

Calls 6

ValidateAppIdFunction · 0.85
ParseAppIdFunction · 0.85
GetAppDirFunction · 0.85
MakeAppIdFunction · 0.85
copyDirFunction · 0.85
StatMethod · 0.80

Tested by

no test coverage detected