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

Wrong name when file does already exist #92

Closed
Shusek opened this issue Jul 14, 2022 · 2 comments
Closed

Wrong name when file does already exist #92

Shusek opened this issue Jul 14, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Shusek
Copy link

Shusek commented Jul 14, 2022

Library version: 1.4.0
OS version: API 30
Device model: Emulator

Describe the bug
When creating a new file while a file with the same name does already exist, the "(2)" is added at the wrong place:

'Some_File.pdf (2) instead 'Some_File (2).pdf'.

To Reproduce
Bug cannot be reproduced on API 24.

File is created by:

  DocumentFileCompat.createDownloadWithMediaStoreFallback(
            context,
            FileDescription(fileName)
        )?.uri
            ?.toDocumentFile(context)

Other:
This regression appeared after the update from 0.14.0 to 1.4.0 version.

@anggrayudi anggrayudi reopened this Jul 15, 2022
@anggrayudi anggrayudi added the bug Something isn't working label Jul 15, 2022
@anggrayudi
Copy link
Owner

For now, the bug can be avoided by setting the mime type explicitly:

val desc = FileDescription("Some_File.pdf", "", "application/pdf")
val filePdf = DocumentFileCompat.createDownloadWithMediaStoreFallback(this, desc)?.uri?.toDocumentFile(this)

Future improvements, maybe v1.4.1 will add automatic mime type detection, so you don't need to add mime type into the argument anymore.

anggrayudi pushed a commit that referenced this issue Jul 15, 2022
anggrayudi pushed a commit that referenced this issue Jul 15, 2022
@anggrayudi
Copy link
Owner

Fixed in v1.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants