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

Preserve file extension for unique filenames #21

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

juntyr
Copy link

@juntyr juntyr commented Sep 24, 2024

When a file is uploaded and has a name clash, a unique filename must be chosen. The current method appends the increment after the pathname, which interferes with the file extension, e.g. README.md becomes README.md_0. (Since the contents API uses the extension to determine how to interpret the file, this causes plain text files to be displayed as base64 encoded). The new variant puts the disambiguator in front to preserve the extension.

Copy link

Binder 👈 Launch a Binder on branch juntyr/litegitpuller/patch-1

@jtpio
Copy link
Member

jtpio commented Sep 24, 2024

Thanks @juntyr for catching this!

It looks like the current implementation would then create a file named 0_README.md?

Wondering if it should be named README_0.md instead, so the files are still next to each others when sorted by name?

@jtpio jtpio added the enhancement New feature or request label Sep 24, 2024
@juntyr
Copy link
Author

juntyr commented Sep 24, 2024

Thanks @juntyr for catching this!

It looks like the current implementation would then create a file named 0_README.md?

Wondering if it should be named README_0.md instead, so the files are still next to each others when sorted by name?

The file will be renamed once the upload of that file is completed anyways, so it will get its original name in the unique upload folder back. But if the name during this upload period matters, then your solution would be nicer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants