refactor(deps): drop cfssl, google/uuid, and x/tools for stdlib equivalents

cfssl was vendored only for sha1.Sum — crypto/sha1 is identical for this
use. google/uuid was used in one debug file while gofrs/uuid is the
project standard. intsets.MaxInt was the sole x/tools consumer;
math.MaxInt replaces it (Go 1.17+).

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
pull/3582/head
Tomas Dvorak 2 weeks ago
parent 47af73a7fd
commit 4c9d57b3b5

@ -10,7 +10,6 @@ require (
github.com/aliyun/alibabacloud-oss-go-sdk-v2 v1.3.0
github.com/aws/aws-sdk-go v1.34.0
github.com/bodgit/sevenzip v1.6.1
github.com/cloudflare/cfssl v1.6.1
github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25
github.com/dsoprea/go-exif/v3 v3.0.1
github.com/dsoprea/go-heic-exif-extractor v0.0.0-20210512044107-62067e44c235
@ -32,7 +31,6 @@ require (
github.com/golang-jwt/jwt/v5 v5.3.0
github.com/gomodule/redigo v1.9.2
github.com/google/go-querystring v1.1.0
github.com/google/uuid v1.6.0
github.com/gorilla/securecookie v1.1.2
github.com/gorilla/sessions v1.2.2
github.com/gorilla/websocket v1.5.3
@ -62,7 +60,6 @@ require (
golang.org/x/image v0.41.0
golang.org/x/text v0.37.0
golang.org/x/time v0.12.0
golang.org/x/tools v0.44.0
modernc.org/sqlite v1.30.0
)
@ -105,9 +102,8 @@ require (
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 // indirect
github.com/google/go-cmp v0.7.0 // indirect
github.com/google/go-tpm v0.9.1 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/context v1.1.2 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl/v2 v2.13.0 // indirect
@ -136,6 +132,9 @@ require (
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.59.1 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/sergi/go-diff v1.2.0 // indirect
github.com/smartystreets/assertions v1.0.0 // indirect
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/sorairolake/lzip-go v0.3.8 // indirect
github.com/spf13/afero v1.15.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
@ -152,6 +151,7 @@ require (
golang.org/x/sync v0.20.0 // indirect
golang.org/x/sys v0.45.0 // indirect
google.golang.org/protobuf v1.36.10 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect

626
go.sum

File diff suppressed because it is too large Load Diff

@ -5,7 +5,7 @@ import (
"entgo.io/ent/dialect"
"entgo.io/ent/dialect/sql"
"fmt"
"github.com/google/uuid"
"github.com/gofrs/uuid"
"time"
)
@ -85,7 +85,7 @@ func (d *DebugDriver) Tx(ctx context.Context) (dialect.Tx, error) {
if err != nil {
return nil, err
}
id := uuid.New().String()
id := uuid.Must(uuid.NewV4()).String()
d.log(ctx, fmt.Sprintf("driver.Tx(%s): started", id))
return &DebugTx{tx, id, d.log, ctx}, nil
}
@ -102,7 +102,7 @@ func (d *DebugDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect
if err != nil {
return nil, err
}
id := uuid.New().String()
id := uuid.Must(uuid.NewV4()).String()
d.log(ctx, fmt.Sprintf("driver.BeginTx(%s): started", id))
return &DebugTx{tx, id, d.log, ctx}, nil
}

@ -21,7 +21,7 @@ import (
"github.com/cloudreve/Cloudreve/v4/pkg/hashid"
"github.com/gofrs/uuid"
"github.com/samber/lo"
"golang.org/x/tools/container/intsets"
"math"
)
const (
@ -438,7 +438,7 @@ func (f *fileClient) SoftDelete(ctx context.Context, file *ent.File) error {
}
func (f *fileClient) RemoveEntitiesByID(ctx context.Context, ids ...int) (map[int]int64, error) {
groups, _ := f.batchInConditionEntityID(intsets.MaxInt, 10, 1, ids)
groups, _ := f.batchInConditionEntityID(math.MaxInt, 10, 1, ids)
// storageReduced stores the relation between owner ID and storage reduced.
storageReduced := make(map[int]int64)
@ -488,7 +488,7 @@ func (f *fileClient) StaleEntities(ctx context.Context, ids ...int) ([]*ent.Enti
res := make([]*ent.Entity, 0, len(ids))
if len(ids) > 0 {
// If explicit IDs are given, we can query them directly
groups, _ := f.batchInConditionEntityID(intsets.MaxInt, 10, 1, ids)
groups, _ := f.batchInConditionEntityID(math.MaxInt, 10, 1, ids)
for _, group := range groups {
entities, err := f.client.Entity.Query().
Where(group).
@ -516,7 +516,7 @@ func (f *fileClient) StaleEntities(ctx context.Context, ids ...int) ([]*ent.Enti
}
func (f *fileClient) DeleteByUser(ctx context.Context, uid int) error {
batchSize := capPageSize(f.maxSQlParam, intsets.MaxInt, 10)
batchSize := capPageSize(f.maxSQlParam, math.MaxInt, 10)
for {
files, err := f.client.File.Query().
WithEntities().
@ -564,7 +564,7 @@ func (f *fileClient) Delete(ctx context.Context, files []*ent.File, options *typ
})
for ref, entityGroup := range entitiesGrouped {
entityPageGroup, _ := f.batchInConditionEntityID(intsets.MaxInt, 10, 1, entityGroup)
entityPageGroup, _ := f.batchInConditionEntityID(math.MaxInt, 10, 1, entityGroup)
for _, group := range entityPageGroup {
if err := f.client.Entity.Update().
Where(group).
@ -576,7 +576,7 @@ func (f *fileClient) Delete(ctx context.Context, files []*ent.File, options *typ
}
// 2. Filter out entities with <=0 reference count, Update recycle options for above entities;
entityGroup, _ := f.batchInConditionEntityID(intsets.MaxInt, 10, 1, uniqueEntities)
entityGroup, _ := f.batchInConditionEntityID(math.MaxInt, 10, 1, uniqueEntities)
toBeRecycled := make([]*ent.Entity, 0, len(entities))
for _, group := range entityGroup {
e, err := f.client.Entity.Query().Where(group).Where(entity.ReferenceCountLTE(0)).All(ctx)
@ -588,7 +588,7 @@ func (f *fileClient) Delete(ctx context.Context, files []*ent.File, options *typ
}
// 3. Update recycle options for above entities;
pageSize := capPageSize(f.maxSQlParam, intsets.MaxInt, 10)
pageSize := capPageSize(f.maxSQlParam, math.MaxInt, 10)
chunks := lo.Chunk(lo.Map(toBeRecycled, func(item *ent.Entity, index int) int {
return item.ID
}), max(pageSize, 1))
@ -602,7 +602,7 @@ func (f *fileClient) Delete(ctx context.Context, files []*ent.File, options *typ
}
hardDeleteCtx := schema.SkipSoftDelete(ctx)
fileGroups, chunks := f.batchInCondition(intsets.MaxInt, 10, 1,
fileGroups, chunks := f.batchInCondition(math.MaxInt, 10, 1,
lo.Map(files, func(file *ent.File, index int) int {
return file.ID
}),
@ -634,7 +634,7 @@ func (f *fileClient) Delete(ctx context.Context, files []*ent.File, options *typ
func (f *fileClient) Copy(ctx context.Context, args *CopyParameter) (map[int][]*ent.File, StorageDiff, error) {
files := args.Files
dstMap := args.DstMap
pageSize := capPageSize(f.maxSQlParam, intsets.MaxInt, 10)
pageSize := capPageSize(f.maxSQlParam, math.MaxInt, 10)
// 1. Copy files and metadata
copyFileStm := lo.Map(files, func(file *ent.File, index int) *ent.FileCreate {
@ -698,7 +698,7 @@ func (f *fileClient) Copy(ctx context.Context, args *CopyParameter) (map[int][]*
return entity.ID, true
})
entityBatch, _ := f.batchInConditionEntityID(intsets.MaxInt, 10, 1, ids)
entityBatch, _ := f.batchInConditionEntityID(math.MaxInt, 10, 1, ids)
entityStm = append(entityStm, lo.Map(entityBatch, func(batch predicate.Entity, index int) *ent.EntityUpdate {
return f.client.Entity.Update().Where(batch).AddReferenceCount(1).AddFile(newFile)
})...)
@ -766,7 +766,7 @@ func (f *fileClient) RemoveMetadata(ctx context.Context, file *ent.File, keys ..
return nil
}
ctx = schema.SkipSoftDelete(ctx)
groups, _ := f.batchInConditionMetadataName(intsets.MaxInt, 10, 1, keys)
groups, _ := f.batchInConditionMetadataName(math.MaxInt, 10, 1, keys)
for _, group := range groups {
if _, err := f.client.Metadata.Delete().Where(metadata.FileID(file.ID), group).Exec(ctx); err != nil {
return fmt.Errorf("failed to remove metadata: %v", err)
@ -1008,7 +1008,7 @@ func (f *fileClient) CreateEntity(ctx context.Context, file *ent.File, args *Ent
}
func (f *fileClient) SetParent(ctx context.Context, files []*ent.File, parent *ent.File) error {
groups, _ := f.batchInCondition(intsets.MaxInt, 10, 1, lo.Map(files, func(file *ent.File, index int) int {
groups, _ := f.batchInCondition(math.MaxInt, 10, 1, lo.Map(files, func(file *ent.File, index int) int {
return file.ID
}))
for _, group := range groups {
@ -1133,7 +1133,7 @@ func (f *fileClient) Rename(ctx context.Context, original *ent.File, newName str
}
func (f *fileClient) GetEntitiesByIDs(ctx context.Context, ids []int, page int) ([]*ent.Entity, int, error) {
groups, _ := f.batchInConditionEntityID(intsets.MaxInt, 10, 1, ids)
groups, _ := f.batchInConditionEntityID(math.MaxInt, 10, 1, ids)
if page >= len(groups) || page < 0 {
return nil, -1, fmt.Errorf("page out of range")
}
@ -1159,7 +1159,7 @@ func (f *fileClient) GetByID(ctx context.Context, ids int) (*ent.File, error) {
}
func (f *fileClient) GetByIDs(ctx context.Context, ids []int, page int) ([]*ent.File, int, error) {
groups, _ := f.batchInCondition(intsets.MaxInt, 10, 1, ids)
groups, _ := f.batchInCondition(math.MaxInt, 10, 1, ids)
if page >= len(groups) || page < 0 {
return nil, -1, fmt.Errorf("page out of range")
}

@ -6,7 +6,7 @@ import (
"encoding/json"
"fmt"
"github.com/cloudflare/cfssl/scan/crypto/sha1"
"crypto/sha1"
"github.com/cloudreve/Cloudreve/v4/application/constants"
"github.com/cloudreve/Cloudreve/v4/inventory/types"
"github.com/cloudreve/Cloudreve/v4/pkg/downloader"

@ -25,7 +25,7 @@ import (
"github.com/cloudreve/Cloudreve/v4/pkg/util"
"github.com/gofrs/uuid"
"github.com/samber/lo"
"golang.org/x/tools/container/intsets"
"math"
)
const (
@ -521,7 +521,7 @@ func (f *DBFS) Get(ctx context.Context, path *fs.URI, opts ...fs.Option) (fs.Fil
// disable load metadata to speed up
ctxWalk := context.WithValue(ctx, inventory.LoadFilePublicMetadata{}, false)
if err := navigator.Walk(ctxWalk, []*File{target}, limit, intsets.MaxInt, func(files []*File, l int) error {
if err := navigator.Walk(ctxWalk, []*File{target}, limit, math.MaxInt, func(files []*File, l int) error {
for _, file := range files {
if file.ID() == target.ID() {
continue

@ -16,7 +16,7 @@ import (
"github.com/cloudreve/Cloudreve/v4/pkg/hashid"
"github.com/cloudreve/Cloudreve/v4/pkg/serializer"
"github.com/samber/lo"
"golang.org/x/tools/container/intsets"
"math"
)
func (f *DBFS) Create(ctx context.Context, path *fs.URI, fileType types.FileType, opts ...fs.Option) (fs.File, error) {
@ -879,7 +879,7 @@ func (f *DBFS) deleteFiles(ctx context.Context, targets map[Navigator][]*File, f
// listing resolves via HasParentWith, so parent rows must stay
// alive until their level has been fetched.
folderModels := make([]*ent.File, 0, 64)
if err := n.Walk(ctx, files, intsets.MaxInt, intsets.MaxInt, func(targets []*File, level int) error {
if err := n.Walk(ctx, files, math.MaxInt, math.MaxInt, func(targets []*File, level int) error {
indexToDelete = append(indexToDelete, lo.Map(targets, func(item *File, index int) int {
return item.ID()
})...)
@ -948,7 +948,7 @@ func (f *DBFS) copyFiles(ctx context.Context, targets map[Navigator][]*File, des
initialDstMap[file.Model.FileChildren] = dstAncestors
}
if err := n.Walk(ctx, files, limit, intsets.MaxInt, func(targets []*File, level int) error {
if err := n.Walk(ctx, files, limit, math.MaxInt, func(targets []*File, level int) error {
// check capacity for each file
sizeTotal := int64(0)
for _, file := range targets {

@ -29,7 +29,7 @@ import (
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/encoding/traditionalchinese"
"golang.org/x/text/encoding/unicode"
"golang.org/x/tools/container/intsets"
"math"
)
type (
@ -186,7 +186,7 @@ func (m *manager) CreateArchive(ctx context.Context, uris []*fs.URI, writer io.W
continue
}
if err := m.Walk(ctx, file.Uri(false), intsets.MaxInt, func(f fs.File, level int) error {
if err := m.Walk(ctx, file.Uri(false), math.MaxInt, func(f fs.File, level int) error {
if f.Type() == types.FileTypeFolder || f.IsSymbolic() {
return nil
}

@ -33,7 +33,7 @@ import (
"github.com/cloudreve/Cloudreve/v4/pkg/util"
"github.com/gin-gonic/gin"
"github.com/samber/lo"
"golang.org/x/tools/container/intsets"
"math"
)
const (
@ -1061,7 +1061,7 @@ func makePropstatResponse(href string, pstats []Propstat) *response {
}
const (
infiniteDepth = intsets.MaxInt
infiniteDepth = math.MaxInt
invalidDepth = -2
)

@ -23,7 +23,7 @@ import (
"github.com/gin-gonic/gin"
"github.com/gofrs/uuid"
"github.com/samber/lo"
"golang.org/x/tools/container/intsets"
"math"
)
// ItemMoveService 处理多文件/目录移动
@ -380,7 +380,7 @@ func (service *ListTaskService) ListTasks(c *gin.Context) (*TaskListResponse, er
if service.Category != "general" {
args.Types = []string{queue.RemoteDownloadTaskType}
if service.Category == "downloading" {
args.PageSize = intsets.MaxInt
args.PageSize = math.MaxInt
args.Status = []task.Status{task.StatusSuspending, task.StatusProcessing, task.StatusQueued}
} else if service.Category == "downloaded" {
args.Status = []task.Status{task.StatusCanceled, task.StatusError, task.StatusCompleted}

Loading…
Cancel
Save