-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
137 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
) | ||
|
||
type LinkArgs struct { | ||
Path string | ||
IP string | ||
Header http.Header | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package fs | ||
|
||
import "errors" | ||
|
||
var ( | ||
ErrMoveBetwwenTwoAccounts = errors.New("can't move files between two account, try to copy") | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package fs | ||
|
||
import ( | ||
"context" | ||
"github.com/alist-org/alist/v3/internal/driver" | ||
"github.com/alist-org/alist/v3/internal/operations" | ||
"github.com/pkg/errors" | ||
) | ||
|
||
func MakeDir(ctx context.Context, account driver.Driver, path string) error { | ||
account, actualPath, err := operations.GetAccountAndActualPath(path) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get account") | ||
} | ||
return operations.MakeDir(ctx, account, actualPath) | ||
} | ||
|
||
func Move(ctx context.Context, account driver.Driver, srcPath, dstPath string) error { | ||
srcAccount, srcActualPath, err := operations.GetAccountAndActualPath(srcPath) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get src account") | ||
} | ||
dstAccount, dstActualPath, err := operations.GetAccountAndActualPath(srcPath) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get dst account") | ||
} | ||
if srcAccount.GetAccount() != dstAccount.GetAccount() { | ||
return errors.WithStack(ErrMoveBetwwenTwoAccounts) | ||
} | ||
return operations.Move(ctx, account, srcActualPath, dstActualPath) | ||
} | ||
|
||
func Rename(ctx context.Context, account driver.Driver, srcPath, dstName string) error { | ||
account, srcActualPath, err := operations.GetAccountAndActualPath(srcPath) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get account") | ||
} | ||
return operations.Rename(ctx, account, srcActualPath, dstName) | ||
} | ||
|
||
// Copy if in an account, call move method | ||
// TODO: if not, add copy task | ||
func Copy(ctx context.Context, account driver.Driver, srcPath, dstPath string) error { | ||
srcAccount, srcActualPath, err := operations.GetAccountAndActualPath(srcPath) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get src account") | ||
} | ||
dstAccount, dstActualPath, err := operations.GetAccountAndActualPath(srcPath) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get dst account") | ||
} | ||
if srcAccount.GetAccount() == dstAccount.GetAccount() { | ||
return operations.Copy(ctx, account, srcActualPath, dstActualPath) | ||
} | ||
// TODO: add copy task, maybe like this: | ||
// operations.Link(ctx,srcAccount,srcActualPath,args) | ||
// get a Reader from link | ||
// boxing the Reader to a driver.FileStream | ||
// operations.Put(ctx,dstParentPath, stream) | ||
panic("TODO") | ||
} | ||
|
||
func Remove(ctx context.Context, account driver.Driver, path string) error { | ||
account, actualPath, err := operations.GetAccountAndActualPath(path) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get account") | ||
} | ||
return operations.Remove(ctx, account, actualPath) | ||
} | ||
|
||
func Put(ctx context.Context, account driver.Driver, parentPath string, file driver.FileStream) error { | ||
account, actualParentPath, err := operations.GetAccountAndActualPath(parentPath) | ||
if err != nil { | ||
return errors.WithMessage(err, "failed get account") | ||
} | ||
return operations.Put(ctx, account, actualParentPath, file) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters