Chore: Add detailed logging to storage.ts to debug saving issues ; Bump to 23.01.5

This commit is contained in:
2026-06-13 01:36:34 +02:00
parent 0cb5e609ed
commit 9e9feff220
4 changed files with 12 additions and 6 deletions
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -359,9 +359,9 @@ export default function CameraScreen({
// Auto-save the high-res original raw photo to the gallery
try {
await saveToGallery(capturedUri, 'Raw', eventText);
console.log('Auto-saved high-res raw capture to gallery');
} catch (e) {
console.error('Failed to auto-save raw capture:', e);
logger.log('Auto-saved high-res raw capture to gallery');
} catch (e: any) {
logger.error(`Failed to auto-save raw capture: ${e?.message || e}`);
}
// Downscale for the UI to prevent OutOfMemoryError in React Native Image
+6 -3
View File
@@ -1,5 +1,6 @@
import { getPermissionsAsync, requestPermissionsAsync, createAssetAsync, getAlbumAsync, createAlbumAsync, addAssetsToAlbumAsync } from 'expo-media-library';
import * as FileSystem from 'expo-file-system';
import { logger } from './logger';
/**
* Request necessary media library permissions.
@@ -36,8 +37,10 @@ function getFormattedDateTime(): string {
* @returns Promise<string> The permanent URI of the saved asset in the gallery.
*/
export async function saveToGallery(localUri: string, type: 'Raw' | 'Collage', eventName: string): Promise<string> {
logger.log(`Starting saveToGallery for ${localUri}`);
const hasPermission = await requestStoragePermission();
if (!hasPermission) {
logger.error('Storage permission not granted. Cannot save photo to gallery.');
throw new Error('Storage permission not granted. Cannot save photo to gallery.');
}
@@ -70,16 +73,16 @@ export async function saveToGallery(localUri: string, type: 'Raw' | 'Collage', e
if (!album) {
// 3. If it doesn't exist, create it with our asset
await createAlbumAsync(ALBUM_NAME, asset, false);
console.log(`Created new album "${ALBUM_NAME}" and copied photo.`);
logger.log(`Created new album "${ALBUM_NAME}" and copied photo.`);
} else {
// 4. If it exists, add our asset to it
await addAssetsToAlbumAsync([asset], album, false);
console.log(`Copied photo to existing album "${ALBUM_NAME}".`);
logger.log(`Copied photo to existing album "${ALBUM_NAME}".`);
}
return asset.uri;
} catch (e: any) {
console.error(`Error saving asset to album ${ALBUM_NAME}:`, e);
logger.error(`Error saving asset to album ${ALBUM_NAME}: ${e?.message || e}`);
return asset.uri;
} finally {
// Cleanup our temp renamed file