added disk quota
This commit is contained in:
parent
4499e88245
commit
9cc2b04342
26 changed files with 1376 additions and 61 deletions
|
|
@ -2,15 +2,15 @@
|
|||
|
||||
package fs
|
||||
|
||||
import "sort"
|
||||
import (
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type Chunk [2]int64
|
||||
|
||||
type Chunks []Chunk
|
||||
|
||||
func (cs Chunks) Len() int { return len(cs) }
|
||||
func (cs Chunks) Less(i, j int) bool { return cs[i][0] < cs[j][0] }
|
||||
func (cs Chunks) Swap(i, j int) { cs[i], cs[j] = cs[j], cs[i] }
|
||||
func (Chunks) Less(i, j Chunk) bool { return i[0] < j[0] }
|
||||
|
||||
func (cs Chunks) Exists(off int64, n int, size int64) bool {
|
||||
end := off + int64(n)
|
||||
|
|
@ -42,7 +42,7 @@ func (cs *Chunks) merge() {
|
|||
if len(c) < 2 {
|
||||
return
|
||||
}
|
||||
sort.Sort(*cs)
|
||||
slices.SortFunc(c, c.Less)
|
||||
for i := 0; i < len(c); i++ {
|
||||
if i+1 == len(c) {
|
||||
break
|
||||
|
|
@ -51,7 +51,7 @@ func (cs *Chunks) merge() {
|
|||
if c[i+1][1] > c[i][1] {
|
||||
c[i][1] = c[i+1][1]
|
||||
}
|
||||
c = append(c[:i+1], c[i+2:]...)
|
||||
c = slices.Delete(c, i+1, i+2)
|
||||
i--
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue