mobile: cleanup downloaded cache files on startup

This commit is contained in:
Ammar Ahmed
2025-12-25 13:52:52 +05:00
parent f6c442ba88
commit ed5c84b069
2 changed files with 16 additions and 8 deletions

View File

@@ -222,15 +222,21 @@ export async function deleteCacheFileByName(name: string) {
}
export async function deleteDCacheFiles() {
await createCacheDir();
const files = await RNFetchBlob.fs.ls(cacheDir);
for (const file of files) {
if (file.includes("_dcache") || file.startsWith("NN_")) {
await RNFetchBlob.fs.unlink(file).catch(() => {
/* empty */
});
try {
await createCacheDir();
const files = await RNFetchBlob.fs.ls(cacheDir);
for (const file of files) {
if (
file.includes("_dcache") ||
file.startsWith("NN_") ||
file.endsWith(".pdf")
) {
await RNFetchBlob.fs.unlink(file).catch(() => {
/* empty */
});
}
}
}
} catch (e) {}
}
export async function getCachePathForFile(filename: string) {

View File

@@ -107,6 +107,7 @@ import { fluidTabsRef } from "../utils/global-refs";
import { NotesnookModule } from "../utils/notesnook-module";
import { sleep } from "../utils/time";
import useFeatureManager from "./use-feature-manager";
import { deleteDCacheFiles } from "../common/filesystem/io";
const onCheckSyncStatus = async (type: SyncStatusEvent) => {
const { disableSync, disableAutoSync } = SettingsService.get();
@@ -457,6 +458,7 @@ const initializeDatabase = async (password?: string) => {
Notifications.setupReminders(true);
DatabaseLogger.info("Database initialized");
Notifications.restorePinnedNotes();
deleteDCacheFiles();
}
Walkthrough.init();
};