|
|
@@ -4,6 +4,7 @@ import (
|
|
|
"context"
|
|
|
"fmt"
|
|
|
"io/fs"
|
|
|
+ "os"
|
|
|
"path/filepath"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
@@ -162,12 +163,22 @@ func (r *MQTTReporter) startYFKJDataBackfill(server MQTTServer) {
|
|
|
baseapp.Logger.Infof("[%s] MQTT服务器 %s ++照片补录开始++", MODULE_NAME, server.Name)
|
|
|
nums2 := 0
|
|
|
filepath.WalkDir(baseapp.IMG_DIR, func(path string, d fs.DirEntry, walkErr error) error {
|
|
|
- if walkErr != nil || d.IsDir() || filepath.Ext(path) != ".jpg" || !strings.HasPrefix(filepath.Base(path), "history-") {
|
|
|
+ if walkErr != nil || d.IsDir() || filepath.Ext(path) != ".jpg" {
|
|
|
return nil
|
|
|
} else if r.ctx.Err() != nil {
|
|
|
return context.Canceled
|
|
|
}
|
|
|
|
|
|
+ if !strings.HasPrefix(filepath.Base(path), "history-") {
|
|
|
+ newPath := filepath.Join(filepath.Dir(path), "history-"+filepath.Base(path))
|
|
|
+ if err := os.Rename(path, newPath); err != nil {
|
|
|
+ baseapp.Logger.Errorf("[%s] 本地照片文件重命名失败, 无法标记为补录照片: %s -> %s, 错误: %v!!",
|
|
|
+ MODULE_NAME, path, newPath, err)
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+ path = newPath
|
|
|
+ }
|
|
|
+
|
|
|
r.uploadPhotoToImagServers(path, true) // 补录上传照片文件
|
|
|
nums2++
|
|
|
|