mirror of
https://github.com/Afilmory/afilmory
synced 2026-04-24 23:05:05 +00:00
feat(data-sync): implement logging for data synchronization process
- Added logging functionality to the DataSyncService to track progress and errors during the manifest generation process. - Introduced DataSyncLogLevel and DataSyncLogPayload types for structured logging. - Updated emitLog method to handle different log levels (info, success, warn, error) and include relevant details. - Enhanced PhotoSyncProgressState to maintain a log of synchronization events, displayed in the PhotoSyncProgressPanel. Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -14,6 +14,9 @@ import type { PickedExif } from '../types/photo.js'
|
||||
export async function extractExifData(imageBuffer: Buffer, originalBuffer?: Buffer): Promise<PickedExif | null> {
|
||||
const log = getGlobalLoggers().exif
|
||||
|
||||
await mkdir('/tmp/image_process', { recursive: true })
|
||||
const tempImagePath = path.resolve('/tmp/image_process', `${crypto.randomUUID()}.jpg`)
|
||||
|
||||
try {
|
||||
log.info('开始提取 EXIF 数据')
|
||||
|
||||
@@ -35,15 +38,10 @@ export async function extractExifData(imageBuffer: Buffer, originalBuffer?: Buff
|
||||
return null
|
||||
}
|
||||
|
||||
await mkdir('/tmp/image_process', { recursive: true })
|
||||
const tempImagePath = path.resolve('/tmp/image_process', `${crypto.randomUUID()}.jpg`)
|
||||
|
||||
await writeFile(tempImagePath, originalBuffer || imageBuffer)
|
||||
const exifData = await exiftool.read(tempImagePath)
|
||||
const result = handleExifData(exifData, metadata)
|
||||
|
||||
await unlink(tempImagePath).catch(noop)
|
||||
|
||||
if (!exifData) {
|
||||
log.warn('EXIF 数据解析失败')
|
||||
return null
|
||||
@@ -59,6 +57,8 @@ export async function extractExifData(imageBuffer: Buffer, originalBuffer?: Buff
|
||||
} catch (error) {
|
||||
log.error('提取 EXIF 数据失败:', error)
|
||||
return null
|
||||
} finally {
|
||||
await unlink(tempImagePath).catch(noop)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user