@@ -413,7 +413,7 @@ private class PlaylistHLSDownloadManager: NSObject, AVAssetDownloadDelegate {
413
413
func urlSession(
414
414
_ session: URLSession ,
415
415
assetDownloadTask: AVAssetDownloadTask ,
416
- didFinishDownloadingTo location: URL
416
+ willDownloadTo location: URL
417
417
) {
418
418
pendingDownloadTasks [ assetDownloadTask] = location
419
419
}
@@ -531,7 +531,8 @@ private class PlaylistHLSDownloadManager: NSObject, AVAssetDownloadDelegate {
531
531
// so we must synchonously move the file to a temporary directory first before processing it
532
532
// on a different thread since the Task will execute after this method returns
533
533
let assetUrl = FileManager . default. temporaryDirectory
534
- . appending ( component: " \( asset. id) - \( temporaryUrl. lastPathComponent) " )
534
+ . appending ( component: asset. id) . appendingPathExtension ( temporaryUrl. pathExtension)
535
+
535
536
try ? FileManager . default. moveItem ( at: temporaryUrl, to: assetUrl)
536
537
537
538
@Sendable func cleanupAndFailDownload( location: URL ? , error: Error ) async {
@@ -920,7 +921,7 @@ private class PlaylistFileDownloadManager: NSObject, URLSessionDownloadDelegate
920
921
// so we must synchonously move the file to a temporary directory first before processing it
921
922
// on a different thread since the Task will execute after this method returns
922
923
let temporaryLocation = FileManager . default. temporaryDirectory
923
- . appending ( component: location. lastPathComponent )
924
+ . appending ( component: asset . id ) . appendingPathExtension ( location. pathExtension )
924
925
try ? FileManager . default. moveItem ( at: location, to: temporaryLocation)
925
926
Task {
926
927
// Couldn't determine file type so we assume mp4 which is the most widely used container.
0 commit comments