mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-05-04 22:26:29 +01:00
fix: storage calculation
This commit is contained in:
@@ -6,6 +6,7 @@ import { File, Paths } from "expo-file-system";
|
|||||||
import type { MutableRefObject } from "react";
|
import type { MutableRefObject } from "react";
|
||||||
import { useCallback } from "react";
|
import { useCallback } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
import DeviceInfo from "react-native-device-info";
|
||||||
import { toast } from "sonner-native";
|
import { toast } from "sonner-native";
|
||||||
import type { Bitrate } from "@/components/BitrateSelector";
|
import type { Bitrate } from "@/components/BitrateSelector";
|
||||||
import useImageStorage from "@/hooks/useImageStorage";
|
import useImageStorage from "@/hooks/useImageStorage";
|
||||||
@@ -286,11 +287,25 @@ export function useDownloadOperations({
|
|||||||
const appSizeUsage = useCallback(async () => {
|
const appSizeUsage = useCallback(async () => {
|
||||||
const totalSize = calculateTotalDownloadedSize();
|
const totalSize = calculateTotalDownloadedSize();
|
||||||
|
|
||||||
return {
|
try {
|
||||||
total: 0,
|
const [freeDiskStorage, totalDiskCapacity] = await Promise.all([
|
||||||
remaining: 0,
|
DeviceInfo.getFreeDiskStorage(),
|
||||||
appSize: totalSize,
|
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 {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user