sftpd: add support for excluding virtual folders from user quota limit

Fixes #110
This commit is contained in:
Nicola Murino
2020-05-01 15:27:53 +02:00
parent 14c2a244b7
commit 3f75d46a16
16 changed files with 340 additions and 139 deletions

View File

@@ -191,6 +191,22 @@ func (u *User) GetPermissionsForPath(p string) []string {
return permissions
}
// IsFileExcludedFromQuota returns true if the file must be excluded from quota usage
func (u *User) IsFileExcludedFromQuota(sftpPath string) bool {
if len(u.VirtualFolders) == 0 || u.FsConfig.Provider != 0 {
return false
}
dirsForPath := utils.GetDirsForSFTPPath(path.Dir(sftpPath))
for _, val := range dirsForPath {
for _, v := range u.VirtualFolders {
if v.VirtualPath == val {
return v.ExcludeFromQuota
}
}
}
return false
}
// AddVirtualDirs adds virtual folders, if defined, to the given files list
func (u *User) AddVirtualDirs(list []os.FileInfo, sftpPath string) []os.FileInfo {
if len(u.VirtualFolders) == 0 {