small fixes and dependency updates
This commit is contained in:
parent
e95910d920
commit
96405e2521
238 changed files with 3599 additions and 3467 deletions
|
|
@ -3,14 +3,15 @@
|
|||
package chunk
|
||||
|
||||
import (
|
||||
"golang.org/x/exp/slices"
|
||||
"cmp"
|
||||
"slices"
|
||||
)
|
||||
|
||||
type Chunk [2]int64
|
||||
|
||||
type Chunks []Chunk
|
||||
|
||||
func (Chunks) Less(i, j Chunk) bool { return i[0] < j[0] }
|
||||
func (Chunks) Comp(a, b Chunk) int { return cmp.Compare(a[0], b[0]) }
|
||||
|
||||
func (cs Chunks) Exists(off int64, n int, size int64) bool {
|
||||
end := off + int64(n)
|
||||
|
|
@ -42,7 +43,7 @@ func (cs *Chunks) merge() {
|
|||
if len(c) < 2 {
|
||||
return
|
||||
}
|
||||
slices.SortFunc(c, c.Less)
|
||||
slices.SortFunc(c, c.Comp)
|
||||
for i := 0; i < len(c); i++ {
|
||||
if i+1 == len(c) {
|
||||
break
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"cachefs/pkg/chunk"
|
||||
"cachefs/pkg/provider"
|
||||
"cachefs/pkg/provider/sftp"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/fs"
|
||||
stdfs "io/fs"
|
||||
"maps"
|
||||
"math"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
|
@ -20,8 +18,11 @@ import (
|
|||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"cachefs/pkg/chunk"
|
||||
"cachefs/pkg/provider"
|
||||
"cachefs/pkg/provider/sftp"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"golang.org/x/exp/maps"
|
||||
)
|
||||
|
||||
func now() int64 {
|
||||
|
|
|
|||
|
|
@ -3,23 +3,24 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"io"
|
||||
"slices"
|
||||
"strconv"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type queue []*Preload
|
||||
|
||||
func (queue) LessReverse(i, j *Preload) bool { return i.Prio > j.Prio }
|
||||
func (queue) CompReverse(a, b *Preload) int { return cmp.Compare(b.Prio, a.Prio) }
|
||||
|
||||
func (q *queue) Sort() {
|
||||
slices.SortFunc(*q, q.LessReverse)
|
||||
slices.SortFunc(*q, q.CompReverse)
|
||||
}
|
||||
|
||||
func (q *queue) Add(ph *PreloadHandler, name string, prio int) {
|
||||
|
|
@ -293,10 +294,7 @@ func (ph *PreloadHandler) preloadStatus(ctx context.Context) {
|
|||
p.stop(false)
|
||||
p.delay = time.Second * 2
|
||||
if p.Errc >= 10 {
|
||||
if p.Prio >= 0 {
|
||||
p.Prio = 0
|
||||
}
|
||||
p.Prio -= 1
|
||||
p.Prio = -10
|
||||
ph.schedule()
|
||||
} else {
|
||||
p.Errc += 1
|
||||
|
|
|
|||
|
|
@ -197,8 +197,11 @@ func (fs *FS) MkdirAll(p string, _ os.FileMode) error {
|
|||
|
||||
func (fs *FS) Close() error {
|
||||
fs.cancel()
|
||||
fs.client.Close()
|
||||
return fs.c.Close()
|
||||
err := fs.client.Close()
|
||||
if fs.c != nil {
|
||||
return fs.c.Close()
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (fs *FS) path(p string) string {
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ package srv
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"cmp"
|
||||
"encoding/xml"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"cachefs/pkg/fs"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
type statusInterceptor struct {
|
||||
|
|
@ -54,7 +54,7 @@ type dir struct {
|
|||
|
||||
type dirs []dir
|
||||
|
||||
func (dirs) Less(i, j dir) bool { return i.Name < j.Name }
|
||||
func (dirs) Comp(a, b dir) int { return cmp.Compare(a.Name, b.Name) }
|
||||
|
||||
type file struct {
|
||||
Name template.HTML
|
||||
|
|
@ -70,7 +70,7 @@ type file struct {
|
|||
|
||||
type files []file
|
||||
|
||||
func (files) Less(i, j file) bool { return i.Name < j.Name }
|
||||
func (files) Comp(a, b file) int { return cmp.Compare(a.Name, b.Name) }
|
||||
|
||||
type responseInterceptor struct {
|
||||
buf bytes.Buffer
|
||||
|
|
@ -145,8 +145,8 @@ func (r *responseInterceptor) GetPaths(path string, filesystem *fs.FS, relative
|
|||
})
|
||||
}
|
||||
}
|
||||
slices.SortFunc(dc.Dirs, dc.Dirs.Less)
|
||||
slices.SortFunc(dc.Files, dc.Files.Less)
|
||||
slices.SortFunc(dc.Dirs, dc.Dirs.Comp)
|
||||
slices.SortFunc(dc.Files, dc.Files.Comp)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,12 @@ package srv
|
|||
|
||||
import (
|
||||
"net/http"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"cachefs/pkg/fs"
|
||||
|
||||
"github.com/go-logr/logr"
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/net/webdav"
|
||||
)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue