Skip to content
This repository was archived by the owner on Oct 3, 2025. It is now read-only.

Commit fbc4b67

Browse files
committed
fix nil measure map
1 parent 84b03c9 commit fbc4b67

5 files changed

Lines changed: 17 additions & 3 deletions

File tree

dashboard/src/views/LogListView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ async function refreshFileList(): Promise<void> {
4040
appLogs.push(f)
4141
continue
4242
}
43-
const data = /^access\.(\d+)\.log(?:\.gz)?$/.exec(f.name)
43+
const data = /^access(?:\.(\d+))?\.log(?:\.gz)?$/.exec(f.name)
4444
if (data) {
45-
accessLogs.push({ n: Number.parseInt(data[1]), f: f })
45+
accessLogs.push({ n: data[1] ? Number.parseInt(data[1]) : 0, f: f })
4646
continue
4747
}
4848
otherLogs.push(f)

lang/en/us.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var areaUS = map[string]string{
6565
"info.sync.none": "All files were synchronized",
6666
"warn.sync.interrupted": "File sync interrupted",
6767
"info.sync.config": "Sync config: %#v",
68+
"error.sync.part.working": "Only %d out of %d storages are working! Sync will begin in a minute",
6869
"hint.sync.total": "Total: ",
6970
"hint.sync.downloading": "> Downloading ",
7071
"hint.sync.downloading.handler": "Downloading %s from handler",

lang/zh/cn.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ var areaCN = map[string]string{
6565
"info.sync.none": "所有文件已同步",
6666
"warn.sync.interrupted": "同步已中断",
6767
"info.sync.config": "同步配置: %#v",
68+
"error.sync.part.working": "仅有 %d / %d 个存储工作正常! 同步将在1分钟内开始",
6869
"hint.sync.total": "总计: ",
6970
"hint.sync.downloading": "> 下载中 ",
7071
"hint.sync.downloading.handler": "Downloading %s from handler",

storage/storage_webdav.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ type WebDavStorage struct {
129129
httpCli *http.Client
130130
noRedCli *http.Client // no redirect client
131131

132-
measures utils.SyncMap[int, struct{}]
132+
measures *utils.SyncMap[int, struct{}]
133133
working atomic.Int32
134134
checkMux sync.RWMutex
135135
lastCheck time.Time
@@ -196,6 +196,7 @@ func (s *WebDavStorage) Init(ctx context.Context) (err error) {
196196
return
197197
}
198198

199+
s.measures = utils.NewSyncMap[int, struct{}]()
199200
if err := s.cli.Mkdir("measure", 0755); err != nil {
200201
if !webdavIsHTTPError(err, http.StatusConflict) {
201202
log.Warnf("Cannot create measure folder for %s: %v", s.String(), err)

sync.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ func (cr *Cluster) syncFiles(ctx context.Context, files []FileInfo, heavyCheck b
529529
err := s.CheckUpload(tctx)
530530
cancel()
531531
if err != nil {
532+
if err := ctx.Err(); err != nil {
533+
return err
534+
}
532535
aliveStorages--
533536
log.Errorf("Storage %s does not work: %v", s.String(), err)
534537
}
@@ -538,6 +541,14 @@ func (cr *Cluster) syncFiles(ctx context.Context, files []FileInfo, heavyCheck b
538541
log.Errorf(Tr("error.sync.failed"), err)
539542
return err
540543
}
544+
if aliveStorages < len(cr.storages) {
545+
log.Errorf(Tr("error.sync.part.working"), aliveStorages < len(cr.storages))
546+
select {
547+
case <-time.After(time.Minute):
548+
case <-ctx.Done():
549+
return ctx.Err()
550+
}
551+
}
541552

542553
for _, f := range missing {
543554
log.Debugf("File %s is for %v", f.Hash, f.targets)

0 commit comments

Comments
 (0)