FIX: Cache destination

This commit is contained in:
Marcos Rodriguez Velez 2024-03-07 10:30:28 -04:00
parent cb375c3a70
commit 1ac7354d24
No known key found for this signature in database
GPG Key ID: 6030B2F48CCE86D7
2 changed files with 5 additions and 5 deletions

View File

@ -883,17 +883,17 @@ class AppStorage {
}
async deleteRealmFilesFromDefaultDirectory() {
const documentsPath = RNFS.DocumentDirectoryPath; // Path to documents folder
const cachesPath = RNFS.CachesDirectoryPath; // Path to caches 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 (!(await RNFS.exists(cachesPath))) return; // If the caches directory does not exist, return (nothing to delete)
const files = await RNFS.readDir(cachesPath); // Read all files in caches 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'),
);
for (const file of appRealmFiles) {
const filePath = `${documentsPath}/${file.name}`;
const filePath = `${cachesPath}/${file.name}`;
const fileExists = await RNFS.exists(filePath); // Check if the file exists
if (fileExists) {
await RNFS.unlink(filePath); // Delete the file if it exists

View File

@ -25,7 +25,7 @@ let _realm;
async function _getRealm() {
if (_realm) return _realm;
const tempFolderPath = RNFS.TemporaryDirectoryPath; // Path to temporary folder
const tempFolderPath = RNFS.CachesDirectoryPath; // Path to temporary folder
const password = bitcoin.crypto.sha256(Buffer.from('fyegjitkyf[eqjnc.lf')).toString('hex');
const buf = Buffer.from(password + password, 'hex');
const encryptionKey = Int8Array.from(buf);