fix for a crash when trying to download a media

This commit is contained in:
Mauro Romito
2026-07-28 16:37:33 +02:00
committed by Mauro
parent 7ea9aeb174
commit 30bc4a06f2
2 changed files with 77 additions and 69 deletions
@@ -21,7 +21,8 @@ protocol PhotoLibraryManagerProtocol {
struct PhotoLibraryManager: PhotoLibraryManagerProtocol {
func addResource(_ type: PHAssetResourceType, at url: URL) async -> Result<Void, PhotoLibraryManagerError> {
do {
try await PHPhotoLibrary.shared().performChanges {
// @Sendable as PhotoKit runs the block on its own queue, so it must not inherit MainActor isolation.
try await PHPhotoLibrary.shared().performChanges { @Sendable in
let request = PHAssetCreationRequest.forAsset()
let options = PHAssetResourceCreationOptions()
request.addResource(with: type, fileURL: url, options: options)