修改bastion的bug

This commit is contained in:
zeaslity
2024-11-17 11:50:16 +08:00
parent 4b1712b67f
commit 07cf7a12b7
2 changed files with 22 additions and 11 deletions

View File

@@ -423,15 +423,26 @@ func BasicFileExists(filename string) bool {
// BasicFileExistAndNotNull 文件不为空返回true 文件为空返回false
func BasicFileExistAndNotNull(filename string) bool {
// 获取文件信息
fileInfo, err := os.Stat(filename)
if err != nil {
// 如果文件不存在或其他错误,返回 false
// Check if the file exists
if _, err := os.Stat(filename); os.IsNotExist(err) {
log.DebugF("文件 %s 不存在!", filename)
return false
}
// 检查文件大小是否大于零
return fileInfo.Size() > 0
// Open the file for reading
file, err := os.Open(filename)
defer file.Close()
if err != nil {
log.DebugF("文件 %s 打开有误!", filename)
return false // Handle error according to your needs
}
// Get the file size
info, _ := file.Stat()
size := info.Size()
// Check if the file is not empty
return size > 0
}
func BasicFolderExists(folderName string) bool {