Skip to content

Commit

Permalink
remove file before block
Browse files Browse the repository at this point in the history
  • Loading branch information
zyxkad committed Jun 9, 2024
1 parent 69d6ab0 commit c29dd31
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
28 changes: 27 additions & 1 deletion dashboard/src/views/LogListView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,41 @@ async function refreshFileList(): Promise<void> {
})
return
}
var files: FileInfo[]
try {
logList.value = await getLogFiles(token.value)
files = await getLogFiles(token.value)
} catch (e) {
toast.add({
severity: 'error',
summary: tr('message.settings.filelist.cant.fetch'),
detail: String(e),
})
return
}
const appLogs: FileInfo[] = []
const accessLogs: { n: number; f: FileInfo }[] = []
const otherLogs: FileInfo[] = []
for (const f of files) {
if (/^\d{8}-\d{2}\.log(?:\.gz)?$/.test(f.name)) {
appLogs.push(f)
continue
}
const data = /^access\.(\d+)\.log(?:\.gz)?$/.exec(f.name)
if (data) {
accessLogs.push({ n: Number.parseInt(data[1]), f: f })
continue
}
otherLogs.push(f)
}
appLogs.sort((a, b) => (a < b ? 1 : -1))
accessLogs.sort(({ n: a }, { n: b }) => a - b)
const logs: FileInfo[] = []
logs.push(...appLogs)
for (const f of accessLogs) {
logs.push(f.f)
}
logs.push(...otherLogs)
logList.value = logs
}
const showInfo = ref<FileInfo | null>(null)
Expand Down
2 changes: 2 additions & 0 deletions sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ func (cr *Cluster) syncFiles(ctx context.Context, files []FileInfo, heavyCheck b
}
}
free()
srcFd.Close()
os.Remove(path)
select {
case done <- failed:
case <-ctx.Done():
Expand Down

0 comments on commit c29dd31

Please sign in to comment.