🚀 dashboard v0.13.31 bytecdn -> staticfile

This commit is contained in:
naiba
2022-06-24 20:43:38 +08:00
parent cf27413b06
commit 6aec814e9e
6 changed files with 71 additions and 66 deletions

View File

@@ -3,11 +3,8 @@ package utils
import (
"crypto/md5" // #nosec
"encoding/hex"
"io"
"log"
"math/rand"
"os"
"path/filepath"
"regexp"
"strings"
"time"
@@ -97,20 +94,7 @@ func SplitIPAddr(v4v6Bundle string) (string, string, string) {
return ipv4, ipv6, validIP
}
func IsTemplateDirEmpty(name string) (bool, error) {
f, err := os.Open(filepath.Join("resource/template/", filepath.Clean(name)))
if err != nil {
return false, err
}
defer func() {
if err := f.Close(); err != nil {
log.Printf("Error closing file: %s\n", err)
}
}()
_, err = f.Readdirnames(1)
if err == io.EOF {
return true, nil
}
return false, err
func IsFileExists(path string) bool {
_, err := os.Stat(path)
return err == nil
}