catalyst / moodle-tool_objectfs

Object file storage system for Moodle
https://moodle.org/plugins/tool_objectfs
88 stars 72 forks source link

Getting an error when accessing a file with size 0 bytes #609

Closed guillogo closed 3 months ago

guillogo commented 7 months ago

Hi all,

I am facing an issue when using objectfs and uploading a file of 0 bytes to Moodle. Whenever I try to access the file, I get an error message. I understand it may sound strange to upload an empty file, but some scorms unfortunately contain references to such files.

Cannot read file 'empty_file0.txt'. Either the file does not exist or there is a permission problem.

[More information about this error](http://docs.moodle.org/401/fr_ca/error/moodle/storedfilecannotreadfile)

Debug info:
Error code: storedfilecannotreadfile
Stack trace:
line 64 of /admin/tool/objectfs/classes/local/store/s3/file_system.php: file_exception thrown
line 444 of /lib/filestorage/stored_file.php: call to tool_objectfs\local\store\s3\file_system->readfile()
line 2335 of /lib/filelib.php: call to stored_file->readfile()
line 2612 of /lib/filelib.php: call to readfile_accel()
line 2766 of /lib/filelib.php: call to send_file()
line 420 of /mod/resource/lib.php: call to send_stored_file()
line 5221 of /lib/filelib.php: call to resource_pluginfile()
line 44 of /pluginfile.php: call to file_pluginfile()

Here are the steps to replicate the issue:

  1. Add a file resource to a course.
  2. Upload the empty_file0.zip file using the file chooser empty_file0.zip
  3. Unzip the file inside the file chooser.
  4. Save the changes.
  5. Click on the new file resource created.

The above steps simulate uploading a SCORM file with a 0-byte file init and referenced.

The error occurs because the file has 0 bytes. The Minimum size threshold (bytes) setting is set to 0.

I am wondering if this is intentional. The file can be accessed/downloaded without issues when objectfs is not used, though.

Thank you!

dmitriim commented 3 months ago

Just hit same issue with one of the scorm packages that needs to access some empty file

petersistrom commented 3 months ago

Resolved by #612