Page 2 of 2
Re: Adding and deleting files that cause over quota
Posted: Fri May 27, 2011 9:06 am
by mellul
Is it possible to be certain that the %FileSize is retrieving the value it should be retrieving? Because I really do not understand why the percentage should turn negative. Your script makes complete sense to me.
Just a quick note on what I am doing - I have set the maximum quota to 10MB and tried to upload a 21.4MB file with your script (without my addition) in the OnQuotaExceeded under the HTTP events, Lua Script Enabled.
I get the Upload Error: Exceeded quota error as it should be, but the quota ends up with the quota bar at -102939.57% and the Quota: -10793996288 Bytes / 10MB
Any help is greatly appreciated.
Re: Adding and deleting files that cause over quota
Posted: Fri May 27, 2011 9:32 am
by FTP
I have modified that script, please copy/paste it again.
Re: Adding and deleting files that cause over quota
Posted: Fri May 27, 2011 12:25 pm
by mellul
It is much better - but for some reason, it is not consistent. I keep uploading the same file to check and sometimes it goes to 0%, now it went to -0.93%, another time -0.3%, another time -0.62%...
Strange - any reason for this?
Re: Adding and deleting files that cause over quota
Posted: Fri May 27, 2011 1:15 pm
by FTP
please change this line:
Code: Select all
tableUser.current_quota = tableUser.max_quota - filesize/1024
into
Code: Select all
tableUser.current_quota = tableUser.max_quota - filesize/1024
if tableUser.current_quota < 0 then
tableUser.current_quota = 0
end
And small deviation is normal.
Re: Adding and deleting files that cause over quota
Posted: Mon May 30, 2011 12:49 pm
by mellul
I have been testing this thoroughly and every now and again something seems to change the ftp users password.
Any idea why this could be so? Also could it be because I am testing on an unregistered copy?
Thanks again
Re: Adding and deleting files that cause over quota
Posted: Mon May 30, 2011 1:04 pm
by mellul
I have found that the password changes to the hashed version when it runs the AddUser line.
How can I fix this please? I can't seem to find I had done anything special when I used this AddUser function before.
Thanks
Re: Adding and deleting files that cause over quota
Posted: Mon May 30, 2011 1:47 pm
by FTP
mellul wrote:I have been testing this thoroughly and every now and again something seems to change the ftp users password.
Any idea why this could be so? Also could it be because I am testing on an unregistered copy?
Thanks again
Please use 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
if tableUser.current_quota < 0 then
tableUser.current_quota = 0
end
tableUser.oldpassword = tableUser.password
AddUser("%Domain",tableUser)
c_RemoveFileDir("%PathName")