release: v1.3.0 — 整站备份恢复、跨后端同步与任务中心
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
ci / ci (22, ubuntu-latest) (push) Canceled after 0s
GitHub Release / release (push) Canceled after 0s
Publish Docker image / build (linux/amd64, ubuntu-latest, amd64) (push) Canceled after 0s
Publish Docker image / build (linux/arm64, ubuntu-24.04-arm, arm64) (push) Canceled after 0s
Publish Docker image / merge (push) Canceled after 0s
This commit is contained in:
1 parent
b05d572221
commit
f17d79b236
72 files changed
+4312
-559
No files matched your search
@@ -0,0 +1,40 @@
|
||||
import { requireAdminAuth } from '../../../utils/access'
|
||||
import { getBackupExportEstimate } from '../../../utils/backup/stats'
|
||||
import { getBackupsDir, isSafeBackupFilename } from '../../../utils/backup/paths'
|
||||
import { promises as fs } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
await requireAdminAuth(event)
|
||||
const estimate = await getBackupExportEstimate()
|
||||
|
||||
const packages = await (async () => {
|
||||
try {
|
||||
await fs.mkdir(getBackupsDir(), { recursive: true })
|
||||
const entries = await fs.readdir(getBackupsDir(), { withFileTypes: true })
|
||||
const items = await Promise.all(
|
||||
entries
|
||||
.filter(entry => entry.isFile() && isSafeBackupFilename(entry.name))
|
||||
.map(async (entry) => {
|
||||
const full = join(getBackupsDir(), entry.name)
|
||||
const fileStat = await fs.stat(full)
|
||||
return {
|
||||
name: entry.name,
|
||||
bytes: fileStat.size,
|
||||
modifiedAt: fileStat.mtime.toISOString()
|
||||
}
|
||||
})
|
||||
)
|
||||
items.sort((a, b) => b.modifiedAt.localeCompare(a.modifiedAt))
|
||||
return items
|
||||
} catch {
|
||||
return []
|
||||
}
|
||||
})()
|
||||
|
||||
return {
|
||||
estimate,
|
||||
backupsDir: getBackupsDir(),
|
||||
packages
|
||||
}
|
||||
})
|
||||
Reference in new issue
Block a user