MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / checkRemoteDir

Function checkRemoteDir

cli/cmd/init/initVM.go:212–243  ·  view source on GitHub ↗

检查远程文件夹

(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command)

Source from the content-addressed store, hash-verified

210
211// 检查远程文件夹
212func checkRemoteDir(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command) error {
213 // 检测指定的文件夹是否有.ide.yaml,有了返回
214 ideFilePath := common.FilePahtJoin4Linux(projectDirPath, ".ide/.ide.yaml")
215 hasIdeConfigYaml := sshRemote.IsFileExist(ideFilePath)
216 if hasIdeConfigYaml {
217 common.SmartIDELog.Info("当前目录已经完成初始化,无须再次进行!")
218 }
219
220 //
221 if !sshRemote.IsDirExist(projectDirPath) { // 目录如果不存在就创建
222 sshRemote.CheckAndCreateDir(projectDirPath)
223 } else {
224 // 检测并阻断
225 isEmpty := sshRemote.IsDirEmpty(projectDirPath) // 检测当前文件夹是否为空
226 if !isEmpty {
227 isContinue, _ := cmd.Flags().GetBool("yes")
228 if !isContinue { // 如果没有设置yes,那么就要给出提示
229 var s string
230 common.SmartIDELog.Importance(i18nInstance.New.Info_noempty_is_comfirm)
231 fmt.Scanln(&s)
232 if s != "y" {
233 return errors.New("user exit")
234 }
235 } else {
236 common.SmartIDELog.Importance("当前文件夹不为空,当前文件夹内数据将被重置。")
237 sshRemote.Clear(projectDirPath)
238 }
239 }
240 }
241
242 return nil
243}

Callers 1

VmInitFunction · 0.70

Calls 7

IsFileExistMethod · 0.80
InfoMethod · 0.80
IsDirExistMethod · 0.80
CheckAndCreateDirMethod · 0.80
IsDirEmptyMethod · 0.80
ImportanceMethod · 0.80
ClearMethod · 0.80

Tested by

no test coverage detected