Automattic / pocket-casts-ios

Pocket Casts iOS app 🎧
Mozilla Public License 2.0
1.66k stars 133 forks source link

Add Mimetype lib and helper #2182

Closed danielebogo closed 1 month ago

danielebogo commented 1 month ago

Fixes #1933

This PR fixes the issue when the HTTP content type doesn't match the file type. To fix it we read the first part of the file and match the correct mime type using Swime. If the file and HTTP types don't match, we update the episode metadata and store the file with the correct type and extension.

To test

[!NOTE] Make sure you have FF useMimetypePackage enabled

Checklist

dangermattic commented 1 month ago
2 Warnings
:warning: Modules/Server/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages in Xcode.
:warning: This PR is assigned to the milestone 7.73 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by :no_entry_sign: Danger

SergioEstevao commented 1 month ago

This is working great, tested with all the podcasts we detected issues and all working great now. Just did some nitpick comments and suggestion to improve it.

danielebogo commented 1 month ago

I think it will be safer to also put a check on the FF on the MetadataTask class in line 51 , to avoid racing conditions between updates to contentType

@SergioEstevao MetadataTask didn't change as the metadata is set before having the file in the temp folder and it happens before the DownloadManager returns the downloaded location.