fix: Convert file created_at to ISO string format

Ensure consistent string representation of file creation timestamps across file storage and type definitions
This commit is contained in:
kangfenmao 2025-03-09 17:11:23 +08:00
parent de1ad09900
commit 670d66b01d
3 changed files with 12 additions and 4 deletions

View File

@ -174,7 +174,7 @@ class FileStorage {
origin_name,
name: uuid + ext,
path: destPath,
created_at: stats.birthtime,
created_at: stats.birthtime.toISOString(),
size: stats.size,
ext: ext,
type: fileType,
@ -198,7 +198,7 @@ class FileStorage {
origin_name: path.basename(filePath),
name: path.basename(filePath),
path: filePath,
created_at: stats.birthtime,
created_at: stats.birthtime.toISOString(),
size: stats.size,
ext: ext,
type: fileType,
@ -416,7 +416,7 @@ class FileStorage {
origin_name: filename,
name: uuid + ext,
path: destPath,
created_at: stats.birthtime,
created_at: stats.birthtime.toISOString(),
size: stats.size,
ext: ext,
type: fileType,

View File

@ -2,6 +2,14 @@ import { Transaction } from 'dexie'
export async function upgradeToV5(tx: Transaction): Promise<void> {
const topics = await tx.table('topics').toArray()
const files = await tx.table('files').toArray()
for (const file of files) {
if (file.created_at instanceof Date) {
file.created_at = file.created_at.toISOString()
await tx.table('files').put(file)
}
}
for (const topic of topics) {
let hasChanges = false

View File

@ -168,7 +168,7 @@ export interface FileType {
size: number
ext: string
type: FileTypes
created_at: Date
created_at: string
count: number
tokens?: number
}