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

Function checkRemoteDir

cli/cmd/new/newVm.go:128–159  ·  view source on GitHub ↗

检查远程文件夹

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

Source from the content-addressed store, hash-verified

126
127// 检查远程文件夹
128func checkRemoteDir(sshRemote common.SSHRemote, projectDirPath string, cmd *cobra.Command) error {
129 // 检测指定的文件夹是否有.ide.yaml,有了返回
130 ideFilePath := common.FilePahtJoin4Linux(projectDirPath, ".ide/.ide.yaml")
131 hasIdeConfigYaml := sshRemote.IsFileExist(ideFilePath)
132 if hasIdeConfigYaml {
133 common.SmartIDELog.Info("当前目录已经完成初始化,无须再次进行!")
134 }
135
136 //
137 if !sshRemote.IsDirExist(projectDirPath) { // 目录如果不存在就创建
138 sshRemote.CheckAndCreateDir(projectDirPath)
139 } else {
140 // 检测并阻断
141 isEmpty := sshRemote.IsDirEmpty(projectDirPath) // 检测当前文件夹是否为空
142 if !isEmpty {
143 isContinue, _ := cmd.Flags().GetBool("yes")
144 if !isContinue { // 如果没有设置yes,那么就要给出提示
145 var s string
146 common.SmartIDELog.Importance(i18nInstance.New.Info_noempty_is_comfirm)
147 fmt.Scanln(&s)
148 if s != "y" {
149 return errors.New("user exit")
150 }
151 } else {
152 common.SmartIDELog.Importance("当前文件夹不为空,当前文件夹内数据将被重置。")
153 sshRemote.Clear(projectDirPath)
154 }
155 }
156 }
157
158 return nil
159}

Callers 1

VmNewFunction · 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