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

View File

@ -2,6 +2,14 @@ import { Transaction } from 'dexie'
export async function upgradeToV5(tx: Transaction): Promise<void> { export async function upgradeToV5(tx: Transaction): Promise<void> {
const topics = await tx.table('topics').toArray() 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) { for (const topic of topics) {
let hasChanges = false let hasChanges = false

View File

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