Small question about quota

Please post here if you have problems in using Wing FTP Server.
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Small question about quota

Post by mellul »

Hi,

I have some small questions about the current quota and maximum quota.

I have been testing the maximum quota and I have found that the current quota sometimes does not match the actual file size inside the folder. This is resulting in an exceed in quota when this is not actually the case.

I am finding this error occuring when I try and upload that same file again. (I do not know if it is because of this)

The current quota does state the current total folder size right?

Another small related question - Is it possible to show the clients maximum quota on the webclient or maybe a percentage of the used quota?

Thanks
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Small question about quota

Post by FTP »

Hi,

The current quota is not total size of folders, it means how much you have uploaded.
And the second question, it does not support to show current quota in the web client, we may consider this feature in the next release.
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Small question about quota

Post by mellul »

So if I would like to fix the size of the total disk quota, say a user can only place a total of 10MB of data in his folder (no matter how much he uploads/deletes), how can I ensure that this is done with your software? This is what other softwares mean by current and maximum quota. How can I do this with your software?

Thanks again
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Small question about quota

Post by mellul »

Hi again,

Please note that when a file is deleted from the FTP client, the current quota still is decreased. So if it was not for the reuploading of a file without deletion, it would represent the total file size.

I hope you can help me here.

Thanks again
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Small question about quota

Post by FTP »

I know your requirement. I think you should add some lua scirpt to FTP's OnFileUploaded event. When this event is triggered, calculate the total size of a specified dierectory, if the total size exceeded some quota, delete the uploaded file.

Code like this:

Code: Select all

local user_dir = "d:/userdir/XX"  --the user directory
local quota_size = 100000000     --quota size, bytes
local total_size = 0                     --the user directory's size

function calDirectorySize(dirname)
	if c_GetFileDir(dirname) ~= nil then
		for isdir,filename in c_GetFileDir(dirname) do
			if isdir == true then
				calDirectorySize(dirname.."/"..filename)
			elseif isdir == false and filename ~= nil and filename ~= "." and filename ~= ".."  then
				local f = assert(io.open(dirname.."/"..filename,"rb")) 
				local filesize = f:seek("end")
				total_size = total_size + filesize
				f:close()
			end
		end
	end
end

calDirectorySize(user_dir)
if total_size > quota_size and "%PathName" ~= "" then
    c_RemoveFileDir("%PathName")
end
Note: for some large directory, the calculating may take a lot of CPU.
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Small question about quota

Post by mellul »

Ok, That seems to work. I have placed it in the HTTP events and FTP events on the OnFileUploaded event. But is it possible to change the quota and directory depending on the user that is uploading the file? For example we have some clients that are allowed only 10MB of space whilst others are allowed more or unlimited space.

Also is it possible to push an error to the client explaining that they have gone above their limit?

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

Re: Small question about quota

Post by FTP »

Different user using different quota size is easy to realize. just add "if..elseif..." statement to the lua script,like this:

if "%Name" == "aa" then
quota_size = 100000000
elseif "%Name" == "bb" then
quota_size = 300000000
elseif "%Name" == "cc" then
quota_size = 500000000
end


But I think with now version, it is impossible to push an error to the client explaining that they have gone above their limit.
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Small question about quota

Post by mellul »

Since we have many ftp customers (about 300), I am seeing this as an impossible task, especially when each new client is added automatically through a script. Also each client has his own directory, so adding a directory, name and quota for each user is going to be a very big task.

Is there a way that we can at least take the user name of the person that has caused the script to execute, so then we can find the directory and maybe I can build a txt file of all the users with their maximum quota so the script can compare to that?

This is a bit of an important step for our company as we do not want users over using their quota.

It would be great if you could add this feature to your next release. It is basically what you already have under the ratio/quota tab - enable disk quota, but the current quota is actually the total size of the folder whilst the max quota is the maximum folder size allowed by the user.
FTP
Site Admin
Posts: 2072
Joined: Tue Sep 29, 2009 6:09 am

Re: Small question about quota

Post by FTP »

Yes, we will consider this feature in the next release.
mellul
Posts: 77
Joined: Mon Nov 16, 2009 2:00 pm

Re: Small question about quota

Post by mellul »

Hi,

I would like to ask if this feature has been considered as it would be an important asset for our company.

Other than that we are finding your software very good.

Thanks
Post Reply