Skip to content

Use stash to upload #860

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

Closed
whym opened this issue Sep 3, 2017 · 5 comments · Fixed by #2505
Closed

Use stash to upload #860

whym opened this issue Sep 3, 2017 · 5 comments · Fixed by #2505

Comments

@whym
Copy link
Collaborator

whym commented Sep 3, 2017

By using the stash-based upload process available in the MediaWiki API, we can decouple the uploading of the file content from the decision of the file name. This can be great because it reduces the chance of the file name being taken by someone else during a long upload process, resulting in an overwrite. (#228)

https://www.mediawiki.org/wiki/API:Upload has some documentation on it. Also, there is a concise code example in Python: https://github.com/wikimedia/mediawiki-extensions-UploadWizard/blob/e3a24c604c36d01ba24f456ecccca54dfa21d016/tests/api/upload-wizard_tests.py#L52

@misaochan
Copy link
Member

Interesting! I agree that this would be useful, but if we were to take advantage of the "name the file later" benefits, we would need to redesign our upload process I believe?

@whym
Copy link
Collaborator Author

whym commented Sep 5, 2017

I think there a couple of possibilities, with varying scope of changes. I believe the options below will not require UI change (but will require changes to the upload process working in the background). What do you think?

  • Shift the timing to check the file name's availability (=the findUniqueFilename method). By doing the check in the last minute (after the file is uploaded), I believe we can make the chance of overwriting smaller.
  • We could start stash-uploading in the background while we wait for the user's input to the title field. This will probably be a larger change than the first one.

@misaochan
Copy link
Member

Option 1 sounds good to me. What do the others think? :)

My concern with Option 2 is, what do we do if the user doesn't complete the process of putting in a title? Currently, that would just mean that the upload doesn't get submitted at all. But if we were to go with Option 2, then if I understand correctly, we would have uploaded a file without any name? Can the file be easily cancelled without needing to go through the Commons deletion nomination process?

@whym
Copy link
Collaborator Author

whym commented Sep 21, 2017

It is a two-stage upload process and in the first stage, the uploaded file will have a temporary name in a temporary space ("stash"), separate from the normal File namespace. If you cancel before finishing the second request, the uploaded material will be gone. At least that's how I understand from the documentation:

the server will stash the file temporarily instead of adding it to the repository.

@nicolas-raoul
Copy link
Member

Working great in my tests.
A small difference I noticed is that files are now uploaded in parallel, rather than one after the other (not sure whether that is related to this PR or not).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants