diff --git a/apps/expo/src/app/(tabs)/settings.tsx b/apps/expo/src/app/(tabs)/settings.tsx index d76bab7..a15bd59 100644 --- a/apps/expo/src/app/(tabs)/settings.tsx +++ b/apps/expo/src/app/(tabs)/settings.tsx @@ -4,6 +4,7 @@ import { Platform } from "react-native"; import Markdown from "react-native-markdown-display"; import * as Application from "expo-application"; import * as Brightness from "expo-brightness"; +import * as FileSystem from "expo-file-system"; import * as WebBrowser from "expo-web-browser"; import { FontAwesome, @@ -87,6 +88,28 @@ export default function SettingsScreen() { } }; + const clearCacheDirectory = async () => { + const cacheDirectory = FileSystem.cacheDirectory + "movie-web"; + if (!cacheDirectory) return; + + try { + await FileSystem.deleteAsync(cacheDirectory, { idempotent: true }); + + toastController.show("Cache cleared", { + burntOptions: { preset: "done" }, + native: true, + duration: 500, + }); + } catch (error) { + console.error("Error clearing cache directory:", error); + toastController.show("Error clearing cache", { + burntOptions: { preset: "error" }, + native: true, + duration: 500, + }); + } + }; + return ( @@ -142,7 +165,7 @@ export default function SettingsScreen() { - Version v{Application.nativeApplicationVersion} + Version {Application.nativeApplicationVersion} + + + Storage + + + } + onPress={() => clearCacheDirectory()} + > + Clear Cache + + diff --git a/apps/expo/src/hooks/DownloadManagerContext.tsx b/apps/expo/src/hooks/DownloadManagerContext.tsx index 68ac580..16e7d4b 100644 --- a/apps/expo/src/hooks/DownloadManagerContext.tsx +++ b/apps/expo/src/hooks/DownloadManagerContext.tsx @@ -223,9 +223,10 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({ lastTimestamp = currentTime; }; - const fileUri = FileSystem.cacheDirectory - ? FileSystem.cacheDirectory + url.split("/").pop() - : null; + const fileUri = + FileSystem.cacheDirectory + "movie-web" + ? FileSystem.cacheDirectory + "movie-web" + url.split("/").pop() + : null; if (!fileUri) { console.error("Cache directory is unavailable"); reject(new Error("Cache directory is unavailable")); @@ -277,7 +278,7 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({ const totalSegments = segments.length; let segmentsDownloaded = 0; - const segmentDir = FileSystem.cacheDirectory + "segments/"; + const segmentDir = FileSystem.cacheDirectory + "movie-web/segments/"; await ensureDirExists(segmentDir); const updateProgress = () => { @@ -326,7 +327,7 @@ export const DownloadManagerProvider: React.FC<{ children: ReactNode }> = ({ updateDownloadItem(downloadId, { statusText: "Merging" }); const uri = await VideoManager.mergeVideos( localSegmentPaths, - `${FileSystem.cacheDirectory}output.mp4`, + `${FileSystem.cacheDirectory}movie-web/output.mp4`, ); const asset = await saveFileToMediaLibraryAndDeleteOriginal( uri,