Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[iOS] - Fix Playlist Crash Deleting Offline Data #25706

Merged
merged 2 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ window.__firefox__.includeOnce("Playlist", function($) {

// Do one last check (if the page took too long to load - DailyMotion)
setTimeout(function() {
checkPageForVideos(false);
fetchMedia();
}, 5000);
}

Expand Down
12 changes: 9 additions & 3 deletions ios/brave-ios/Sources/Playlist/PlaylistDownloadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ private class PlaylistHLSDownloadManager: NSObject, AVAssetDownloadDelegate {
// HLS streams can be in two spots, we need to delete from both
// just in case the download process was in the middle of transferring the asset
// to its proper location
if let cacheLocation = delegate?.localAsset(for: asset.id)?.url {
if let cacheLocation = await MainActor.run(body: {
delegate?.localAsset(for: asset.id)?.url
}) {
do {
try await AsyncFileManager.default.removeItem(at: cacheLocation)
} catch {
Expand Down Expand Up @@ -739,7 +741,9 @@ private class PlaylistFileDownloadManager: NSObject, URLSessionDownloadDelegate
if let error = error as NSError? {
switch (error.domain, error.code) {
case (NSURLErrorDomain, NSURLErrorCancelled):
if let cacheLocation = delegate?.localAsset(for: asset.id)?.url {
if let cacheLocation = await MainActor.run(body: {
delegate?.localAsset(for: asset.id)?.url
}) {
do {
try await AsyncFileManager.default.removeItem(at: cacheLocation)
PlaylistItem.updateCache(uuid: asset.id, pageSrc: asset.pageSrc, cachedData: nil)
Expand Down Expand Up @@ -1060,7 +1064,9 @@ private class PlaylistDataDownloadManager: NSObject, URLSessionDataDelegate {
if let error = error as NSError? {
switch (error.domain, error.code) {
case (NSURLErrorDomain, NSURLErrorCancelled):
if let cacheLocation = delegate?.localAsset(for: asset.id)?.url {
if let cacheLocation = await MainActor.run(body: {
delegate?.localAsset(for: asset.id)?.url
}) {
Task {
do {
try await AsyncFileManager.default.removeItem(at: cacheLocation)
Expand Down
Loading