|
|
@ -318,12 +318,12 @@ export class CapacitorPlatformService implements PlatformService { |
|
|
|
async writeAndShareFile(fileName: string, content: string): Promise<void> { |
|
|
|
const timestamp = new Date().toISOString(); |
|
|
|
const logData = { |
|
|
|
action: 'writeAndShareFile', |
|
|
|
action: "writeAndShareFile", |
|
|
|
fileName, |
|
|
|
contentLength: content.length, |
|
|
|
timestamp, |
|
|
|
}; |
|
|
|
logger.log('[CapacitorPlatformService]', JSON.stringify(logData, null, 2)); |
|
|
|
logger.log("[CapacitorPlatformService]", JSON.stringify(logData, null, 2)); |
|
|
|
|
|
|
|
try { |
|
|
|
const { uri } = await Filesystem.writeFile({ |
|
|
@ -334,13 +334,16 @@ export class CapacitorPlatformService implements PlatformService { |
|
|
|
recursive: true, |
|
|
|
}); |
|
|
|
|
|
|
|
logger.log('[CapacitorPlatformService] File write successful:', { uri, timestamp: new Date().toISOString() }); |
|
|
|
logger.log("[CapacitorPlatformService] File write successful:", { |
|
|
|
uri, |
|
|
|
timestamp: new Date().toISOString(), |
|
|
|
}); |
|
|
|
|
|
|
|
await Share.share({ |
|
|
|
title: 'TimeSafari Backup', |
|
|
|
text: 'Here is your backup file.', |
|
|
|
title: "TimeSafari Backup", |
|
|
|
text: "Here is your backup file.", |
|
|
|
url: uri, |
|
|
|
dialogTitle: 'Share your backup file', |
|
|
|
dialogTitle: "Share your backup file", |
|
|
|
}); |
|
|
|
} catch (error) { |
|
|
|
const err = error as Error; |
|
|
@ -349,7 +352,10 @@ export class CapacitorPlatformService implements PlatformService { |
|
|
|
stack: err.stack, |
|
|
|
timestamp: new Date().toISOString(), |
|
|
|
}; |
|
|
|
logger.error('[CapacitorPlatformService] Error writing or sharing file:', JSON.stringify(errLog, null, 2)); |
|
|
|
logger.error( |
|
|
|
"[CapacitorPlatformService] Error writing or sharing file:", |
|
|
|
JSON.stringify(errLog, null, 2), |
|
|
|
); |
|
|
|
throw new Error(`Failed to write or share file: ${err.message}`); |
|
|
|
} |
|
|
|
} |
|
|
|