diff --git a/BlueApp.js b/BlueApp.js index 1e12de302..b969e61d6 100644 --- a/BlueApp.js +++ b/BlueApp.js @@ -885,7 +885,9 @@ class AppStorage { async deleteRealmFilesFromDefaultDirectory() { const documentsPath = RNFS.DocumentDirectoryPath; // Path to documents folder try { + if (!(await RNFS.exists(documentsPath))) return; // If the documents directory does not exist, return (nothing to delete const files = await RNFS.readDir(documentsPath); // Read all files in documents directory + if (Array.isArray(files) && files.length === 0) return; // If there are no files, return (nothing to delete const appRealmFiles = files.filter( file => file.name.endsWith('.realm') || file.name.endsWith('.realm.lock') || file.name.includes('.realm.management'), );