sftpgo-copy: add quota limits check

This commit is contained in:
Nicola Murino
2020-06-16 22:49:18 +02:00
parent c491133aff
commit 3ceba7a147
7 changed files with 264 additions and 45 deletions

View File

@@ -293,24 +293,6 @@ func (u *User) HasOverlappedMappedPaths() bool {
return false
}
// GetRemaingQuotaSize returns the available quota size for the given SFTP path
func (u *User) GetRemaingQuotaSize(sftpPath string) int64 {
vfolder, err := u.GetVirtualFolderForPath(sftpPath)
if err == nil {
if vfolder.IsIncludedInUserQuota() && u.QuotaSize > 0 {
return u.QuotaSize - u.UsedQuotaSize
}
if vfolder.QuotaSize > 0 {
return vfolder.QuotaSize - vfolder.UsedQuotaSize
}
} else {
if u.QuotaSize > 0 {
return u.QuotaSize - u.UsedQuotaSize
}
}
return 0
}
// HasPerm returns true if the user has the given permission or any permission
func (u *User) HasPerm(permission, path string) bool {
perms := u.GetPermissionsForPath(path)