mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-01-15 15:48:05 +00:00
wip
This commit is contained in:
@@ -18,7 +18,10 @@ import { toast } from "sonner-native";
|
|||||||
import { Text } from "@/components/common/Text";
|
import { Text } from "@/components/common/Text";
|
||||||
import type { StorageLocation } from "@/modules";
|
import type { StorageLocation } from "@/modules";
|
||||||
import { useSettings } from "@/utils/atoms/settings";
|
import { useSettings } from "@/utils/atoms/settings";
|
||||||
import { getAvailableStorageLocations } from "@/utils/storage";
|
import {
|
||||||
|
clearStorageLocationsCache,
|
||||||
|
getAvailableStorageLocations,
|
||||||
|
} from "@/utils/storage";
|
||||||
|
|
||||||
interface StorageLocationPickerProps {
|
interface StorageLocationPickerProps {
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
@@ -47,6 +50,7 @@ export const StorageLocationPicker = forwardRef<
|
|||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
updateSettings({ downloadStorageLocation: selectedId });
|
updateSettings({ downloadStorageLocation: selectedId });
|
||||||
|
clearStorageLocationsCache(); // Clear cache so next download uses new location
|
||||||
toast.success(
|
toast.success(
|
||||||
t("settings.storage.storage_location_updated", {
|
t("settings.storage.storage_location_updated", {
|
||||||
defaultValue: "Storage location updated",
|
defaultValue: "Storage location updated",
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { Directory, File, Paths } from "expo-file-system";
|
import { Directory, File } from "expo-file-system";
|
||||||
import { getAllDownloadedItems, getDownloadedItemById } from "./database";
|
import { getAllDownloadedItems, getDownloadedItemById } from "./database";
|
||||||
import type { DownloadedItem } from "./types";
|
import type { DownloadedItem } from "./types";
|
||||||
import { filePathToUri } from "./utils";
|
import { filePathToUri } from "./utils";
|
||||||
@@ -39,13 +39,11 @@ export function deleteAllAssociatedFiles(item: DownloadedItem): void {
|
|||||||
stream.DeliveryUrl
|
stream.DeliveryUrl
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
const subtitleFilename = stream.DeliveryUrl.split("/").pop();
|
// Use the full path from DeliveryUrl (it's already a full file:// URI)
|
||||||
if (subtitleFilename) {
|
const subtitleFile = new File(stream.DeliveryUrl);
|
||||||
const subtitleFile = new File(Paths.document, subtitleFilename);
|
if (subtitleFile.exists) {
|
||||||
if (subtitleFile.exists) {
|
subtitleFile.delete();
|
||||||
subtitleFile.delete();
|
console.log(`[DELETE] Subtitle deleted: ${stream.DeliveryUrl}`);
|
||||||
console.log(`[DELETE] Subtitle deleted: ${subtitleFilename}`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[DELETE] Failed to delete subtitle:", error);
|
console.error("[DELETE] Failed to delete subtitle:", error);
|
||||||
@@ -57,15 +55,13 @@ export function deleteAllAssociatedFiles(item: DownloadedItem): void {
|
|||||||
// Delete trickplay directory
|
// Delete trickplay directory
|
||||||
if (item.trickPlayData?.path) {
|
if (item.trickPlayData?.path) {
|
||||||
try {
|
try {
|
||||||
const trickplayDirName = item.trickPlayData.path.split("/").pop();
|
// Use the full path from trickPlayData (it's already a full file:// URI)
|
||||||
if (trickplayDirName) {
|
const trickplayDir = new Directory(item.trickPlayData.path);
|
||||||
const trickplayDir = new Directory(Paths.document, trickplayDirName);
|
if (trickplayDir.exists) {
|
||||||
if (trickplayDir.exists) {
|
trickplayDir.delete();
|
||||||
trickplayDir.delete();
|
console.log(
|
||||||
console.log(
|
`[DELETE] Trickplay directory deleted: ${item.trickPlayData.path}`,
|
||||||
`[DELETE] Trickplay directory deleted: ${trickplayDirName}`,
|
);
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("[DELETE] Failed to delete trickplay directory:", error);
|
console.error("[DELETE] Failed to delete trickplay directory:", error);
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { Paths } from "expo-file-system";
|
import { Directory, Paths } from "expo-file-system";
|
||||||
import { Platform } from "react-native";
|
import { Platform } from "react-native";
|
||||||
import { BackgroundDownloader, type StorageLocation } from "@/modules";
|
import { BackgroundDownloader, type StorageLocation } from "@/modules";
|
||||||
|
|
||||||
let cachedStorageLocations: StorageLocation[] | null = null;
|
let cachedStorageLocations: StorageLocation[] | null = null;
|
||||||
|
|
||||||
|
// Debug mode: Set to true to simulate an SD card for testing in emulator
|
||||||
|
// This creates a real writable directory that mimics SD card behavior
|
||||||
|
const DEBUG_SIMULATE_SD_CARD = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all available storage locations (Android only)
|
* Get all available storage locations (Android only)
|
||||||
* Returns cached result on subsequent calls
|
* Returns cached result on subsequent calls
|
||||||
@@ -21,6 +25,29 @@ export async function getAvailableStorageLocations(): Promise<
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const locations = await BackgroundDownloader.getAvailableStorageLocations();
|
const locations = await BackgroundDownloader.getAvailableStorageLocations();
|
||||||
|
|
||||||
|
// Debug mode: Add a functional simulated SD card for testing
|
||||||
|
if (DEBUG_SIMULATE_SD_CARD && locations.length === 1) {
|
||||||
|
// Use a real writable path within the app's document directory
|
||||||
|
const sdcardSimDir = new Directory(Paths.document, "sdcard_sim");
|
||||||
|
|
||||||
|
// Create the directory if it doesn't exist
|
||||||
|
if (!sdcardSimDir.exists) {
|
||||||
|
sdcardSimDir.create({ intermediates: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
const mockSdCard: StorageLocation = {
|
||||||
|
id: "sdcard_sim",
|
||||||
|
path: sdcardSimDir.uri.replace("file://", ""),
|
||||||
|
type: "external",
|
||||||
|
label: "SD Card (Simulated)",
|
||||||
|
totalSpace: 64 * 1024 * 1024 * 1024, // 64 GB
|
||||||
|
freeSpace: 32 * 1024 * 1024 * 1024, // 32 GB free
|
||||||
|
};
|
||||||
|
locations.push(mockSdCard);
|
||||||
|
console.log("[DEBUG] Added simulated SD card:", mockSdCard.path);
|
||||||
|
}
|
||||||
|
|
||||||
cachedStorageLocations = locations;
|
cachedStorageLocations = locations;
|
||||||
return locations;
|
return locations;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user