Adding and deleting files that cause over quota

Here you can submit your bug reports.
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Adding and deleting files that cause over quota

Post by mellul »

I was testing your new version today and found that when I upload a file that causes the quota to be exceeded, the file is still uploaded to the point that the quota is full, no more is uploaded hence the file becomes corrupted. When I try to delete that file, it will not delete because the file is corrupted.

Is this a bug and can it be fixed as well please? I believe it should check that the file to be uploaded fits before it attempts upload and if it doesn't it should be discarded with an error message advising user that the file exceeds quota.

Thanks once again for your help.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Adding and deleting files that cause over quota

Post by FTP »

First, one thing you should know, there is no method to detect the total file size until file is uploaded. You should have a look on the FTP protocol.

Then, when you exceeded the disk quota, you can still delete the uploaded file, so why can't you delete?
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Adding and deleting files that cause over quota

Post by mellul »

Say I have 10MB quota FTP and I try and upload a 21MB pdf file. When uploading, at 10MB I get a an error stating that the quota was exceeded - that is fine... I don't really mind that.

The problem lies here. I click ok and close and I find that the file is listed like it has been uploaded (except with a smaller size as it could not fully upload). So I can see, as a person who understands I can see that this file is corrupted but a user who is not technical, may not realize this.

I tried to delete again and now it works. Not sure what went wrong first. If I come across it again I will advise.

I personally don't really like the fact that it stays there though as some clients would not know that it is corrupted and will assume it is our problem. could this be fixed?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Adding and deleting files that cause over quota

Post by FTP »

Yes, maybe you were right, maybe you can't delete files sometimes, we will test it again.

And we will let "%PathName" available within the Event OnQuotaExceeded, then you can delete that file by yourself, is it OK?
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Adding and deleting files that cause over quota

Post by mellul »

What I suggest is that if a file is not fully uploaded, the software should automatically remove the file which is not fully uploaded. For the client, it should be like they never tried to upload it in the first place and not have a corrupted file in their FTP that they have to remove.

Please advise if this is not clear and I will try and explain in a different way
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Adding and deleting files that cause over quota

Post by FTP »

Yes, I know what you want, so I said new version will let "%PathName" available within the HTTP Event OnQuotaExceeded, then you can delete that file by yourself, just a simple Lua script.

BTW, not everyone want to remove the corrupted file automatically, for example, someone want to upload a huge file via FTP, when he uploaded 10G, then he exceeded the disk quota, but if administrator extend his disk quota, then he can resume uploading without removing it.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Adding and deleting files that cause over quota

Post by FTP »

New version has been released, now it allows variables "%PathName","%FileName","%FileSize" in the HTTP Event OnQuotaExceeded. So you just need to add the following lua script into the event OnQuotaExceeded:

Code: Select all

c_RemoveFileDir("%PathName")
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Adding and deleting files that cause over quota

Post by mellul »

The script worked perfectly in removing the uploaded file in the new version, but it does not fix the quota back to where it should be once the file is removed. That is, although the file that was uploaded was removed, the quota still stayed at 100%.

Do I need to add more to the script to fix this issue, or could it be another bug?
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Adding and deleting files that cause over quota

Post by FTP »

The function "c_RemoveFileDir" is just for removing file, if you want to decrease the quota size, just write the following lua script:

Code: Select all

  
   local tableUser = c_GetUser("%Domain","%Name")

   for k,v in pairs(tableUser) do
      if type(v) == "boolean" then
         if v == true then
            tableUser[k] = 1
         else
            tableUser[k] = 0
         end
      end
   end

   local filesize = tonumber("%FileSize")
   tableUser.current_quota = tableUser.max_quota - filesize/1024
   
   AddUser("%Domain",tableUser)
   c_RemoveFileDir("%PathName")
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Adding and deleting files that cause over quota

Post by mellul »

Worked great thanks.

The only thing that happened though is that the quota went negative. I added the following piece of script to solve that:

Code: Select all

if tableUser.current_quota < 0 then
	tableUser.current_quota = 0
end
It seems to have solved that problem.

Although I still have another problem to sort through - as this deletes the full file size and not the size it uploaded successfully only

Thanks again.
Post Reply