-
-
Notifications
You must be signed in to change notification settings - Fork 166
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
Rewrite the WeBWorK::Upload module. #2693
base: develop
Are you sure you want to change the base?
Conversation
=over | ||
An upload stored in the upload cache can be retrieved by supplying its temporary | ||
file name and hash (accessible from the above C<tmpFile> and C<hash> methods, | ||
respectively. The file can then be accessed by name or file handle, moved, and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor thing: close the ) after 'respectively' ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. That is fixed.
Thinking about testing this. There's clearly the email that came from the issue, but does this get called for a file upload to through the File Manager? I notice the code in |
There are currently two places this is used, and you mentioned both of them. |
We should also remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with uploading to the File Manager. Didn't test with emails.
I believe that the |
This takes advantage of things available with Mojolicious. This does not use `Data::UUID` anymore. A comment stated that it was overkill. It is and it was never a good idea to use that for this purpose. This just uses the `Mojo::Asset::Memory::to_file` method which converts to a `Mojo::Asset::File` object and saves the file to a temporary file using `Mojo::File::tempfile` (which uses `File::Temp` under the hood). That is guaranteed to give a safe filename that does not conflict with any existing files. Setting the environment variable `MOJO_TMPDIR` locally to be the passed in directory (which is `$ce->{webworkDirs}{uploadCache}`) ensures that the file is saved in the usual webwork2 upload location (although there is no need for that, and we could drop that configuration variable and just use the system temporary directory for this). The info file that is written is now UTF-8 encoded and decoded. This fixes issue openwebwork#2690. The `dir` option which was previously required and the only "option" is now just a required argument. It doesn't make sense to use an "option" hash things that are required. Particularly if there is only one option and it is required. Other than what is mentioned above the module behaves much the same.
This takes advantage of things available with Mojolicious.
This does not use
Data::UUID
anymore. A comment stated that it was overkill. It is and it was never a good idea to use that for this purpose. This just uses theMojo::Asset::Memory::to_file
method which converts to aMojo::Asset::File
object and saves the file to a temporary file usingMojo::File::tempfile
(which usesFile::Temp
under the hood). That is guaranteed to give a safe filename that does not conflict with any existing files. Setting the environment variableMOJO_TMPDIR
locally to be the passed in directory (which is$ce->{webworkDirs}{uploadCache}
) ensures that the file is saved in the usual webwork2 upload location (although there is no need for that, and we could drop that configuration variable and just use the system temporary directory for this).The info file that is written is now UTF-8 encoded and decoded. This fixes issue #2690.
The
dir
option which was previously required and the only "option" is now just a required argument. It doesn't make sense to use an "option" hash things that are required. Particularly if there is only one option and it is required.Other than what is mentioned above the module behaves much the same.