fix: storage calculation

This commit is contained in:
Fredrik Burmester
2025-11-11 09:25:27 +01:00
parent 76ec8e0e46
commit de6c2072c9

View File

@@ -6,6 +6,7 @@ import { File, Paths } from "expo-file-system";
import type { MutableRefObject } from "react";
import { useCallback } from "react";
import { useTranslation } from "react-i18next";
import DeviceInfo from "react-native-device-info";
import { toast } from "sonner-native";
import type { Bitrate } from "@/components/BitrateSelector";
import useImageStorage from "@/hooks/useImageStorage";
@@ -286,11 +287,25 @@ export function useDownloadOperations({
const appSizeUsage = useCallback(async () => {
const totalSize = calculateTotalDownloadedSize();
return {
total: 0,
remaining: 0,
appSize: totalSize,
};
try {
const [freeDiskStorage, totalDiskCapacity] = await Promise.all([
DeviceInfo.getFreeDiskStorage(),
DeviceInfo.getTotalDiskCapacity(),
]);
return {
total: totalDiskCapacity,
remaining: freeDiskStorage,
appSize: totalSize,
};
} catch (error) {
console.error("Failed to get disk storage info:", error);
return {
total: 0,
remaining: 0,
appSize: totalSize,
};
}
}, []);
return {