|
|
|
@ -4,6 +4,7 @@ import (
|
|
|
|
|
"context"
|
|
|
|
|
"encoding/json"
|
|
|
|
|
"fmt"
|
|
|
|
|
"io/fs"
|
|
|
|
|
"os"
|
|
|
|
|
|
|
|
|
|
"github.com/estebangarcia21/subprocess"
|
|
|
|
@ -56,7 +57,7 @@ func startLocalServer(name, dir, cmd string) {
|
|
|
|
|
s.ExecAsync()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// StartServer - запускает сервер на выполение
|
|
|
|
|
// StartServer - запускает сервер на выполнение
|
|
|
|
|
func (a *App) StartServer(s string) string {
|
|
|
|
|
runtime.LogInfo(a.ctx, s)
|
|
|
|
|
var server Server
|
|
|
|
@ -84,11 +85,38 @@ func (a *App) Weed() {
|
|
|
|
|
runtime.LogInfo(a.ctx, fmt.Sprintf("команда выполнена успешно"))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *App) GetStatus() string {
|
|
|
|
|
func getCountPics(dir string) int {
|
|
|
|
|
pics, err := os.ReadDir("d:\\pics")
|
|
|
|
|
if err != nil {
|
|
|
|
|
runtime.LogError(a.ctx, err.Error())
|
|
|
|
|
return "error: " + err.Error()
|
|
|
|
|
return -1
|
|
|
|
|
}
|
|
|
|
|
return len(pics)
|
|
|
|
|
}
|
|
|
|
|
return fmt.Sprint(len(pics))
|
|
|
|
|
|
|
|
|
|
// The `getCountReady` function is counting the number of files (excluding directories) in a
|
|
|
|
|
// specified directory. It uses the `fs.WalkDir` function to walk through the file tree starting
|
|
|
|
|
// from the given directory within a file system. For each file encountered during the walk, it
|
|
|
|
|
// increments a counter if the file is not a directory. Finally, it returns the total count of
|
|
|
|
|
// files found in the directory.
|
|
|
|
|
func getCountReady(ctx context.Context, dir string) int {
|
|
|
|
|
root := dir
|
|
|
|
|
fileSystem := os.DirFS(root)
|
|
|
|
|
|
|
|
|
|
cnt := 0
|
|
|
|
|
fs.WalkDir(fileSystem, ".", func(path string, d fs.DirEntry, err error) error {
|
|
|
|
|
if err != nil {
|
|
|
|
|
runtime.LogError(ctx, err.Error())
|
|
|
|
|
}
|
|
|
|
|
if !d.IsDir() {
|
|
|
|
|
cnt += 1
|
|
|
|
|
}
|
|
|
|
|
return nil
|
|
|
|
|
})
|
|
|
|
|
return cnt
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (a *App) GetStatus() string {
|
|
|
|
|
pics := getCountPics("d:\\pics")
|
|
|
|
|
ready := getCountReady(a.ctx, "d:\\pics-move")
|
|
|
|
|
return fmt.Sprintf("%d/%d", pics, ready)
|
|
|
|
|
}
|
|
|
|
|