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

DocumentFileExtensions.kt: Use simple string operations to preserve extension when renaming #293

Merged
merged 1 commit into from
Apr 14, 2023

Conversation

chenxiaolong
Copy link
Owner

MimeTypeMap's getExtensionFromMimeType() and getMimeTypeFromExtension() are not consistent with each other. Querying the extension for audio/mp4 returns m4a as expected, but querying the MIME type for m4a returns audio/mpeg, which is associated with the mp3 extension.

Due to this, whenever an output file needed to be renamed, files that originally had the m4a extension would get changed to mp3. This commit fixes the issue by removing the whole extension -> MIME type -> extension round trip when renaming files. Instead, it just appends everything after the last dot from the original filename when renaming.

Fixes: #292

…xtension when renaming

MimeTypeMap's getExtensionFromMimeType() and getMimeTypeFromExtension()
are not consistent with each other. Querying the extension for
`audio/mp4` returns `m4a` as expected, but querying the MIME type for
`m4a` returns `audio/mpeg`, which is associated with the `mp3`
extension.

Due to this, whenever an output file needed to be renamed, files that
originally had the `m4a` extension would get changed to `mp3`. This
commit fixes the issue by removing the whole extension -> MIME type ->
extension round trip when renaming files. Instead, it just appends
everything after the last dot from the original filename when renaming.

Fixes: #292

Signed-off-by: Andrew Gunnerson <[email protected]>
@chenxiaolong chenxiaolong self-assigned this Apr 14, 2023
@chenxiaolong chenxiaolong merged commit 63bcaf2 into master Apr 14, 2023
chenxiaolong added a commit that referenced this pull request Apr 14, 2023
Signed-off-by: Andrew Gunnerson <[email protected]>
@chenxiaolong chenxiaolong deleted the mimetype branch April 14, 2023 02:05
chenxiaolong added a commit that referenced this pull request Jul 2, 2023
This fixes a regression in #361, which reintroduced #292/#293.

Fixes: #367

Signed-off-by: Andrew Gunnerson <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BCR sometimes incorrectly uses .mp3 file extension
1 participant