You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
665 B
Go
41 lines
665 B
Go
package namespace
|
|
|
|
type FileSizeQuota struct {
|
|
AllowanceKB int64
|
|
CurrentUsage int64
|
|
}
|
|
|
|
func (f FileSizeQuota) Allows(size int64) bool {
|
|
return f.Remaining() >= size
|
|
}
|
|
|
|
func (f FileSizeQuota) Remaining() int64 {
|
|
return f.AllowanceKB - f.CurrentUsage
|
|
}
|
|
|
|
func (f FileSizeQuota) Add(size int64) FileSizeQuota {
|
|
return FileSizeQuota {
|
|
f.AllowanceKB,
|
|
f.CurrentUsage + size,
|
|
}
|
|
}
|
|
|
|
func (f FileSizeQuota) Remove(size int64) FileSizeQuota {
|
|
return FileSizeQuota {
|
|
f.AllowanceKB,
|
|
f.CurrentUsage - size,
|
|
}
|
|
}
|
|
|
|
type FileStat struct {
|
|
Num int64
|
|
SizeB int64
|
|
}
|
|
|
|
func (s FileStat) Add(size int64) FileStat {
|
|
return FileStat{
|
|
s.Num + 1,
|
|
s.SizeB + size,
|
|
}
|
|
}
|