mirror of https://github.com/Xhofe/alist
* feat(ftp-server): treat moving across file systems as copying * fix: ensure compatibility across different fs on the same driverpull/7673/head
parent
b72e85a73a
commit
40b0e66efe
|
@ -2,6 +2,7 @@ package ftp
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
"github.com/alist-org/alist/v3/internal/errs"
|
"github.com/alist-org/alist/v3/internal/errs"
|
||||||
"github.com/alist-org/alist/v3/internal/fs"
|
"github.com/alist-org/alist/v3/internal/fs"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
|
@ -64,9 +65,15 @@ func Rename(ctx context.Context, oldPath, newPath string) error {
|
||||||
if !user.CanFTPManage() || !user.CanMove() || (srcBase != dstBase && !user.CanRename()) {
|
if !user.CanFTPManage() || !user.CanMove() || (srcBase != dstBase && !user.CanRename()) {
|
||||||
return errs.PermissionDenied
|
return errs.PermissionDenied
|
||||||
}
|
}
|
||||||
if err := fs.Move(ctx, srcPath, dstDir); err != nil {
|
if err = fs.Move(ctx, srcPath, dstDir); err != nil {
|
||||||
|
if srcBase != dstBase {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
if _, err1 := fs.Copy(ctx, srcPath, dstDir); err1 != nil {
|
||||||
|
return fmt.Errorf("failed move for %+v, and failed try copying for %+v", err, err1)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if srcBase != dstBase {
|
if srcBase != dstBase {
|
||||||
return fs.Rename(ctx, stdpath.Join(dstDir, srcBase), dstBase)
|
return fs.Rename(ctx, stdpath.Join(dstDir, srcBase), dstBase)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue