chore: update Go version to 1.26.5 and improve error handling in remote client

master
Aaron Liu 1 week ago
parent 20c95ad73f
commit 65f8c3f3ed

@ -3,7 +3,7 @@ trigger:
include: include:
- '*' - '*'
variables: variables:
GO_VERSION: "1.25.5" GO_VERSION: "1.26.5"
NODE_VERSION: "22.x" NODE_VERSION: "22.x"
DOCKER_BUILDKIT: 1 DOCKER_BUILDKIT: 1

@ -1,8 +1,8 @@
module github.com/cloudreve/Cloudreve/v4 module github.com/cloudreve/Cloudreve/v4
go 1.25.0 go 1.26.0
toolchain go1.25.5 toolchain go1.26.5
require ( require (
entgo.io/ent v0.13.0 entgo.io/ent v0.13.0

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"context" "context"
"encoding/json" "encoding/json"
"errors"
"fmt" "fmt"
"io" "io"
"net/http" "net/http"
@ -177,7 +178,7 @@ func (c *remoteClient) DeleteFiles(ctx context.Context, files ...string) ([]stri
if resp.Code == serializer.CodeNotFullySuccess { if resp.Code == serializer.CodeNotFullySuccess {
resp.GobDecode(&failed) resp.GobDecode(&failed)
} }
return failed, fmt.Errorf(resp.Error) return failed, errors.New(resp.Error)
} }
return nil, nil return nil, nil
@ -196,7 +197,7 @@ func (c *remoteClient) MediaMeta(ctx context.Context, src, ext, language string)
} }
if resp.Code != 0 { if resp.Code != 0 {
return nil, fmt.Errorf(resp.Error) return nil, errors.New(resp.Error)
} }
var metas []driver.MediaMeta var metas []driver.MediaMeta

@ -764,7 +764,7 @@ func (f *DBFS) getNavigator(ctx context.Context, path *fs.URI, requiredCapabilit
capabilities := res.Capabilities(false).Capability capabilities := res.Capabilities(false).Capability
for _, capability := range requiredCapabilities { for _, capability := range requiredCapabilities {
if !capabilities.Enabled(int(capability)) { if !capabilities.Enabled(int(capability)) {
return nil, fs.ErrNotSupportedAction.WithError(fmt.Errorf("action %q is not supported under current fs", capability)) return nil, fs.ErrNotSupportedAction.WithError(fmt.Errorf("action %v is not supported under current fs", capability))
} }
} }

@ -319,7 +319,7 @@ func lockTupleFromUri(uri *fs.URI, u *ent.User, hasher hashid.Encoder) (string,
if id == "" { if id == "" {
id = strconv.Itoa(u.ID) id = strconv.Itoa(u.ID)
} }
ns := fmt.Sprintf(id + "/" + string(uri.FileSystem())) ns := id + "/" + string(uri.FileSystem())
root := uri.Path() root := uri.Path()
return ns, root, ns + "/" + root return ns, root, ns + "/" + root
} }

@ -54,7 +54,7 @@ func (f *DBFS) Create(ctx context.Context, path *fs.URI, fileType types.FileType
// File with the same name but different type already exist // File with the same name but different type already exist
return nil, fs.ErrFileExisted. return nil, fs.ErrFileExisted.
WithError(fmt.Errorf("object with the same name but different type %q already exist", ancestor.Type())) WithError(fmt.Errorf("object with the same name but different type %v already exist", ancestor.Type()))
} }
if _, ok := ctx.Value(ByPassOwnerCheckCtxKey{}).(bool); !ok && ancestor.Owner().ID != f.user.ID { if _, ok := ctx.Value(ByPassOwnerCheckCtxKey{}).(bool); !ok && ancestor.Owner().ID != f.user.ID {

Loading…
Cancel
Save