znuny / Znuny

Znuny/Znuny LTS is a fork of the ((OTRS)) Community Edition, one of the most flexible web-based ticketing systems used for Customer Service, Help Desk, IT Service Management.
https://www.znuny.org
GNU General Public License v3.0
377 stars 88 forks source link

Bug - UsedSpace is calculated too early in Core.UI.js #604

Open BuilderNSV opened 5 days ago

BuilderNSV commented 5 days ago

Environment

Expected behavior

UsedSpace is calcuated after a new file is really uploaded in Core.UI.js

Actual behavior

UsedSpace is calcuated before all error conditions have been passed in Core.UI.js.

How to reproduce

Steps to reproduce the behavior:

  1. Set WebMaxFileUpload to 100000 in Core.UI.js (the easiest way to reproduce)
  2. Set MaxSizePerFile to 50000 in Core.UI.js (the easiest way to reproduce)
  3. Prepare 2 files
    • 1st of size less than WebMaxFileUpload - for example 80000 bytes.
    • 2nd of size less than MaxSizePerFile but more than free space calculated after trying to upload 1st file - for example 30000 bytes.
  4. Start to create ticket
  5. Select to add attachments - both 1st and 2nd files at once
  6. See error message "No space left for the following files" for the 2nd file
  7. Try to add as attachment only 2nd file
  8. Check that it is added successfully
hanneshal commented 5 days ago

Hi @BuilderNSV can you please explain, what the actual user error would be in your case? WebMaxFileUpload is a Sysconfig and can easily be modified in the GUI (Admin->Sysconfig). As far as I can tell, MaxSizePerFile is never really used because it fallbacks to the acutual file size of the uploaded file.

Hence we never had an issue related to this, I would like to understand what the acutal user error would be / is.

Thanks!

BuilderNSV commented 2 days ago

Hi @hanneshal,

WebMaxFileUpload is a Sysconfig and can easily be modified in the GUI (Admin->Sysconfig).

I knew that WebMaxFileUpload can be modified in Sysconfig. I write my step with direct changing of value just for the easest way to reporduce.

As far as I can tell, MaxSizePerFile is never really used because it fallbacks to the acutual file size of the uploaded file.

I write about MaxSizePerFile because I have limited by 'max_allowed_packet' value of my MySQL server (8Mb) but I need to satisfy recomendations of Installer to have WebMaxFileUpload >= 64Mb. So I limited users by adding an attachment of size no more than 8Mb via MaxSizePerFile parameter.

On the other hand, the issue is not related to MaxSizePerFile parameter only but it's related to uploading a group of files at once. If you take a look on Core.UI.js, line 631, you will see that File.size is added to UsedSpace but some checks on errors have not yet finished after this line. If some of conditions become true, File.size is taken into account of UsedSpace but file is not really uploaded and not eat used space. So if first several files in group of uploaded files are rejected by an error and UsedSpace becomes close to WebMaxFileUpload, some valid file in group will not be able to be uploaded because UsedSpace has been exhausted.

can you please explain, what the actual user error would be in your case?

I can't upload files of such small size by unknown reason. So I set WebMaxFileUpload = 6000000, MaxSizePerFile = 1100000 and prepare 2 files: