From 4663c435c99b1c6f29b0e8841fe2150d85cb0667 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Wed, 15 Apr 2026 06:11:07 +0200 Subject: [PATCH] fix: artwork directory null crash on orientation change --- lib/services/download_storage_service.dart | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/services/download_storage_service.dart b/lib/services/download_storage_service.dart index 0ec7d838..c3fde7f2 100644 --- a/lib/services/download_storage_service.dart +++ b/lib/services/download_storage_service.dart @@ -52,6 +52,7 @@ class DownloadStorageService { _customPathType = _settingsService!.getCustomDownloadPathType(); _baseDownloadsDir = null; _artworkDirectoryPath = null; + await getArtworkDirectory(); } } @@ -154,12 +155,10 @@ class DownloadStorageService { } /// Get artwork file path from Plex thumb path (synchronous, requires initialization) - /// Returns path to cached artwork file using hash of the thumb URL + /// Returns path to cached artwork file using hash of the thumb URL, or null if not initialized /// Example: artwork/a1b2c3d4e5f6.jpg - String getArtworkPathSync(String serverId, String thumbPath) { - if (_artworkDirectoryPath == null) { - throw StateError('Artwork directory not initialized. Call getArtworkDirectory() first.'); - } + String? getArtworkPathSync(String serverId, String thumbPath) { + if (_artworkDirectoryPath == null) return null; // Create hash from serverId:thumbPath for deduplication final hash = _hashArtworkPath(serverId, thumbPath); return path.join(_artworkDirectoryPath!, '$hash.jpg');