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

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

Open
BuilderNSV opened this issue Oct 18, 2024 · 2 comments
Open

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

BuilderNSV opened this issue Oct 18, 2024 · 2 comments
Assignees

Comments

@BuilderNSV
Copy link
Contributor

Environment

  • Server OS: Linux
  • Browser: Firefox
  • Znuny version: 7.1.3

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.
  1. Start to create ticket
  2. Select to add attachments - both 1st and 2nd files at once
  3. See error message "No space left for the following files" for the 2nd file
  4. Try to add as attachment only 2nd file
  5. Check that it is added successfully
@hanneshal
Copy link

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!

@hanneshal hanneshal self-assigned this Oct 18, 2024
@BuilderNSV
Copy link
Contributor Author

BuilderNSV commented Oct 21, 2024

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:

  • wrong1.sql - size 5001909 bytes
  • 1mb.sql - size 1019482 bytes
    And tried to upload them at once and see next error screen:
    изображение
    As you can see - wrong1.sql is rejected correctly - its size is more than MaxSizePerFile
    But 1mb.sql is rejected incorrectly - free space is still 5.7MB (because wrong1.sql was not uploaded) but I see "Available space 974.7 KB ..."

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

No branches or pull requests

2 participants