Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb17dd9fe7 | ||
|
|
14b56fa7dc |
No files matched your search
@@ -283,7 +283,7 @@ jobs:
|
||||
run: govulncheck ./...
|
||||
|
||||
- name: Check Markdown format
|
||||
uses: DavidAnson/markdownlint-cli2-action@v23
|
||||
uses: DavidAnson/markdownlint-cli2-action@v20
|
||||
with:
|
||||
globs: |
|
||||
CONTRIBUTING.md
|
||||
|
||||
+7
-7
@@ -412,8 +412,8 @@ the source file in the `Help:` field:
|
||||
- The `backenddocs` make target runs the Python script `bin/make_backend_docs.py`,
|
||||
and you can also run this directly, optionally with the name of a backend
|
||||
as argument to only update the docs for a specific backend.
|
||||
- **Do not** commit the updated Markdown files. This operation is run as part
|
||||
of the release process. Since any manual changes in the autogenerated sections
|
||||
- **Do not** commit the updated Markdown files. This operation is run as part of
|
||||
the release process. Since any manual changes in the autogenerated sections
|
||||
of the Markdown files will then be lost, we have a pull request check that
|
||||
reports error for any changes within the autogenerated sections. Should you
|
||||
have done manual changes outside of the autogenerated sections they must be
|
||||
@@ -580,8 +580,7 @@ remote or an fs.
|
||||
make sure we can encode any path name and `rclone info` to help determine the
|
||||
encodings needed
|
||||
- `rclone purge -v TestRemote:rclone-info`
|
||||
- `rclone test info --all --remote-encoding None -vv --write-json remote.json
|
||||
TestRemote:rclone-info`
|
||||
- `rclone test info --all --remote-encoding None -vv --write-json remote.json TestRemote:rclone-info`
|
||||
- `go run cmd/test/info/internal/build_csv/main.go -o remote.csv remote.json`
|
||||
- open `remote.csv` in a spreadsheet and examine
|
||||
|
||||
@@ -628,9 +627,10 @@ See the [testing](#testing) section for more information on integration tests.
|
||||
|
||||
### Backend documentation
|
||||
|
||||
Add your backend to the docs. Keep lists of remotes in alphabetical
|
||||
order of full name of remote (e.g. `drive` is ordered as `Google
|
||||
Drive`) but with the local file system last.
|
||||
Add your backend to the docs - you'll need to pick an icon for it from
|
||||
[fontawesome](http://fontawesome.io/icons/). Keep lists of remotes in
|
||||
alphabetical order of full name of remote (e.g. `drive` is ordered as
|
||||
`Google Drive`) but with the local file system last.
|
||||
|
||||
First add a data file about your backend in
|
||||
`docs/data/backends/remote.yaml` - this is used to build the overview
|
||||
|
||||
+20
-20
@@ -2,27 +2,27 @@
|
||||
|
||||
Current active maintainers of rclone are:
|
||||
|
||||
| Name | GitHub ID | Specific Responsibilities |
|
||||
| :--------------- | :---------------- | :------------------------------------- |
|
||||
| Nick Craig-Wood | @ncw | overall project health |
|
||||
| Stefan Breunig | @breunigs | |
|
||||
| Ishuah Kariuki | @ishuah | |
|
||||
| Remus Bunduc | @remusb | cache backend |
|
||||
| Fabian Möller | @B4dM4n | |
|
||||
| Alex Chen | @Cnly | onedrive backend |
|
||||
| Sandeep Ummadi | @sandeepkru | azureblob backend |
|
||||
| Name | GitHub ID | Specific Responsibilities |
|
||||
| :--------------- | :---------------- | :-------------------------- |
|
||||
| Nick Craig-Wood | @ncw | overall project health |
|
||||
| Stefan Breunig | @breunigs | |
|
||||
| Ishuah Kariuki | @ishuah | |
|
||||
| Remus Bunduc | @remusb | cache backend |
|
||||
| Fabian Möller | @B4dM4n | |
|
||||
| Alex Chen | @Cnly | onedrive backend |
|
||||
| Sandeep Ummadi | @sandeepkru | azureblob backend |
|
||||
| Sebastian Bünger | @buengese | jottacloud, yandex & compress backends |
|
||||
| Ivan Andreev | @ivandeex | chunker & mailru backends |
|
||||
| Max Sum | @Max-Sum | union backend |
|
||||
| Fred | @creativeprojects | seafile backend |
|
||||
| Caleb Case | @calebcase | storj backend |
|
||||
| wiserain | @wiserain | pikpak backend |
|
||||
| albertony | @albertony | |
|
||||
| Chun-Hung Tseng | @henrybear327 | Proton Drive Backend |
|
||||
| Hideo Aoyama | @boukendesho | snap packaging |
|
||||
| nielash | @nielash | bisync |
|
||||
| Dan McArdle | @dmcardle | gitannex |
|
||||
| Sam Harrison | @childish-sambino | filescom |
|
||||
| Ivan Andreev | @ivandeex | chunker & mailru backends |
|
||||
| Max Sum | @Max-Sum | union backend |
|
||||
| Fred | @creativeprojects | seafile backend |
|
||||
| Caleb Case | @calebcase | storj backend |
|
||||
| wiserain | @wiserain | pikpak backend |
|
||||
| albertony | @albertony | |
|
||||
| Chun-Hung Tseng | @henrybear327 | Proton Drive Backend |
|
||||
| Hideo Aoyama | @boukendesho | snap packaging |
|
||||
| nielash | @nielash | bisync |
|
||||
| Dan McArdle | @dmcardle | gitannex |
|
||||
| Sam Harrison | @childish-sambino | filescom |
|
||||
|
||||
## This is a work in progress draft
|
||||
|
||||
|
||||
@@ -123,7 +123,6 @@ directories to and from different cloud storage providers.
|
||||
- Synology C2 Object Storage [:page_facing_up:](https://rclone.org/s3/#synology-c2)
|
||||
- Tencent Cloud Object Storage (COS) [:page_facing_up:](https://rclone.org/s3/#tencent-cos)
|
||||
- Uloz.to [:page_facing_up:](https://rclone.org/ulozto/)
|
||||
- US3 Object Storage [:page_facing_up:](https://rclone.org/s3/#us3)
|
||||
- Wasabi [:page_facing_up:](https://rclone.org/s3/#wasabi)
|
||||
- WebDAV [:page_facing_up:](https://rclone.org/webdav/)
|
||||
- Yandex Disk [:page_facing_up:](https://rclone.org/yandex/)
|
||||
|
||||
+603
-139
@@ -29,6 +29,7 @@ import (
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
@@ -222,17 +223,17 @@ All other operations will be disabled.`,
|
||||
}, {
|
||||
Name: "shared_folders",
|
||||
Help: `Instructs rclone to work on shared folders.
|
||||
|
||||
When this flag is used with no path only the List operation is supported and
|
||||
all available shared folders will be listed. If you specify a path the first part
|
||||
will be interpreted as the name of shared folder. Rclone will then try to mount this
|
||||
shared to the root namespace. On success shared folder rclone proceeds normally.
|
||||
The shared folder is now pretty much a normal folder and all normal operations
|
||||
are supported.
|
||||
|
||||
Note that we don't unmount the shared folder afterwards so the
|
||||
--dropbox-shared-folders can be omitted after the first use of a particular
|
||||
shared folder.
|
||||
When this flag is used with no path only the List operation is supported and
|
||||
all available shared folders will be listed. If you specify a path the first part
|
||||
will be interpreted as the name of shared folder and rclone will list and access
|
||||
files within it using the shared folder's namespace. This works for all shared
|
||||
folder types including team folders.
|
||||
|
||||
Write operations (upload, delete, mkdir, copy, move) are supported within
|
||||
shared folders. Server-side copy and move operations only work within the
|
||||
same shared folder - cross-shared-folder operations will fall back to
|
||||
upload/download.
|
||||
|
||||
See also --dropbox-root-namespace for an alternative way to work with shared
|
||||
folders.`,
|
||||
@@ -320,22 +321,25 @@ type Options struct {
|
||||
|
||||
// Fs represents a remote dropbox server
|
||||
type Fs struct {
|
||||
name string // name of this remote
|
||||
root string // the path we are working on
|
||||
opt Options // parsed options
|
||||
ci *fs.ConfigInfo // global config
|
||||
features *fs.Features // optional features
|
||||
srv files.Client // the connection to the dropbox server
|
||||
svc files.Client // the connection to the dropbox server (unauthorized)
|
||||
sharing sharing.Client // as above, but for generating sharing links
|
||||
users users.Client // as above, but for accessing user information
|
||||
team team.Client // for the Teams API
|
||||
slashRoot string // root with "/" prefix, lowercase
|
||||
slashRootSlash string // root with "/" prefix and postfix, lowercase
|
||||
pacer *fs.Pacer // To pace the API calls
|
||||
ns string // The namespace we are using or "" for none
|
||||
batcher *batcher.Batcher[*files.UploadSessionFinishArg, *files.FileMetadata]
|
||||
exportExts []exportExtension
|
||||
name string // name of this remote
|
||||
root string // the path we are working on
|
||||
opt Options // parsed options
|
||||
ci *fs.ConfigInfo // global config
|
||||
features *fs.Features // optional features
|
||||
srv files.Client // the connection to the dropbox server
|
||||
svc files.Client // the connection to the dropbox server (unauthorized)
|
||||
sharing sharing.Client // as above, but for generating sharing links
|
||||
users users.Client // as above, but for accessing user information
|
||||
team team.Client // for the Teams API
|
||||
slashRoot string // root with "/" prefix, lowercase
|
||||
slashRootSlash string // root with "/" prefix and postfix, lowercase
|
||||
pacer *fs.Pacer // To pace the API calls
|
||||
ns string // The namespace we are using or "" for none
|
||||
batcher *batcher.Batcher[*files.UploadSessionFinishArg, *files.FileMetadata]
|
||||
exportExts []exportExtension
|
||||
cfg dropbox.Config // SDK config for creating per-namespace clients
|
||||
sharedFolderMu sync.Mutex // protects sharedFolderIDs
|
||||
sharedFolderIDs map[string]string // cache of shared folder name → namespace ID
|
||||
}
|
||||
|
||||
type exportType int
|
||||
@@ -358,11 +362,50 @@ type Object struct {
|
||||
bytes int64 // size of the object
|
||||
modTime time.Time // time it was last modified
|
||||
hash string // content_hash of the object
|
||||
nsID string // shared folder namespace ID, if applicable
|
||||
|
||||
exportType exportType
|
||||
exportAPIFormat exportAPIFormat
|
||||
}
|
||||
|
||||
// fileSrv returns the files client to use for this object.
|
||||
// If the object belongs to a shared folder, it returns a
|
||||
// namespace-scoped client; otherwise it returns the default client.
|
||||
func (o *Object) fileSrv() files.Client {
|
||||
if o.nsID != "" {
|
||||
nsCfg := o.fs.cfg.WithNamespaceID(o.nsID)
|
||||
return files.New(nsCfg)
|
||||
}
|
||||
return o.fs.srv
|
||||
}
|
||||
|
||||
// sharedFolderSrvAndPath resolves an rclone path in shared_folders mode
|
||||
// to a namespace-scoped files client and the API path within that namespace.
|
||||
// The rclone path format is "SharedFolderName/sub/path/file.txt".
|
||||
func (f *Fs) sharedFolderSrvAndPath(ctx context.Context, rclonePath string) (srv files.Client, apiPath string, nsID string, err error) {
|
||||
firstDir, subPath, _ := strings.Cut(rclonePath, "/")
|
||||
nsID, err = f.findSharedFolder(ctx, firstDir)
|
||||
if err != nil {
|
||||
return nil, "", "", err
|
||||
}
|
||||
srv = files.New(f.cfg.WithNamespaceID(nsID))
|
||||
if subPath != "" {
|
||||
apiPath = f.opt.Enc.FromStandardPath("/" + subPath)
|
||||
}
|
||||
return srv, apiPath, nsID, nil
|
||||
}
|
||||
|
||||
// nsPath returns the encoded API path for use with namespace-scoped clients.
|
||||
// In shared_folders mode the object's remote is "SharedFolder/sub/file.txt"
|
||||
// but the API path within the namespace is just "/sub/file.txt".
|
||||
func (o *Object) nsPath() string {
|
||||
if o.nsID != "" {
|
||||
_, subPath, _ := strings.Cut(o.remote, "/")
|
||||
return o.fs.opt.Enc.FromStandardPath("/" + subPath)
|
||||
}
|
||||
return o.fs.opt.Enc.FromStandardPath(o.remotePath())
|
||||
}
|
||||
|
||||
// Name of the remote (as passed into NewFs)
|
||||
func (f *Fs) Name() string {
|
||||
return f.name
|
||||
@@ -537,6 +580,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
||||
cfg.AsMemberID = memberIDs[0].MemberInfo.Profile.MemberProfile.TeamMemberId
|
||||
}
|
||||
|
||||
f.cfg = cfg
|
||||
f.srv = files.New(cfg)
|
||||
f.svc = files.New(ucfg)
|
||||
f.sharing = sharing.New(cfg)
|
||||
@@ -564,7 +608,8 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
||||
if f.opt.SharedFolders {
|
||||
f.setRoot(root)
|
||||
if f.root == "" {
|
||||
return f, nil // our root it empty so we probably want to list shared folders
|
||||
f.features.Fill(ctx, f)
|
||||
return f, nil // our root is empty so we probably want to list shared folders
|
||||
}
|
||||
|
||||
dir := path.Dir(f.root)
|
||||
@@ -830,9 +875,53 @@ func (f *Fs) NewObject(ctx context.Context, remote string) (fs.Object, error) {
|
||||
if f.opt.SharedFiles {
|
||||
return f.findSharedFile(ctx, remote)
|
||||
}
|
||||
if f.opt.SharedFolders {
|
||||
return f.newSharedFolderObject(ctx, remote)
|
||||
}
|
||||
return f.newObjectWithInfo(ctx, remote, nil)
|
||||
}
|
||||
|
||||
// newSharedFolderObject finds an Object inside a shared folder by
|
||||
// using the shared folder's namespace ID to resolve the path.
|
||||
func (f *Fs) newSharedFolderObject(ctx context.Context, remote string) (fs.Object, error) {
|
||||
firstDir, subPath, ok := strings.Cut(remote, "/")
|
||||
if !ok {
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
id, err := f.findSharedFolder(ctx, firstDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
nsCfg := f.cfg.WithNamespaceID(id)
|
||||
nsSrv := files.New(nsCfg)
|
||||
|
||||
filePath := f.opt.Enc.FromStandardPath("/" + subPath)
|
||||
var entry files.IsMetadata
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
entry, err = nsSrv.GetMetadata(&files.GetMetadataArg{Path: filePath})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.GetMetadataAPIError:
|
||||
if e.EndpointError != nil && e.EndpointError.Path != nil && e.EndpointError.Path.Tag == files.LookupErrorNotFound {
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
fileInfo, ok := entry.(*files.FileMetadata)
|
||||
if !ok {
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
o, err := f.newObjectWithInfo(ctx, remote, fileInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
o.(*Object).nsID = id
|
||||
return o, nil
|
||||
}
|
||||
|
||||
// listSharedFolders lists all available shared folders mounted and not mounted
|
||||
// we'll need the id later so we have to return them in original format
|
||||
func (f *Fs) listSharedFolders(ctx context.Context, callback func(fs.DirEntry) error) (err error) {
|
||||
@@ -879,24 +968,128 @@ func (f *Fs) listSharedFolders(ctx context.Context, callback func(fs.DirEntry) e
|
||||
return nil
|
||||
}
|
||||
|
||||
// listDir lists the contents of a directory using the given files client.
|
||||
// root is the Dropbox API path to list, dir is the rclone directory prefix for results.
|
||||
// nsID is the shared folder namespace ID to set on created objects (empty for normal listings).
|
||||
func (f *Fs) listDir(ctx context.Context, srv files.Client, root string, dir string, nsID string, list *list.Helper) (err error) {
|
||||
started := false
|
||||
var res *files.ListFolderResult
|
||||
for {
|
||||
if !started {
|
||||
arg := files.NewListFolderArg(f.opt.Enc.FromStandardPath(root))
|
||||
arg.Recursive = false
|
||||
arg.Limit = 1000
|
||||
if root == "/" || root == "" {
|
||||
arg.Path = "" // Specify root folder as empty string
|
||||
}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
res, err = srv.ListFolder(arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.ListFolderAPIError:
|
||||
if e.EndpointError != nil && e.EndpointError.Path != nil && e.EndpointError.Path.Tag == files.LookupErrorNotFound {
|
||||
err = fs.ErrorDirNotFound
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
started = true
|
||||
} else {
|
||||
arg := files.ListFolderContinueArg{
|
||||
Cursor: res.Cursor,
|
||||
}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
res, err = srv.ListFolderContinue(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("list continue: %w", err)
|
||||
}
|
||||
}
|
||||
for _, entry := range res.Entries {
|
||||
var fileInfo *files.FileMetadata
|
||||
var folderInfo *files.FolderMetadata
|
||||
var metadata *files.Metadata
|
||||
switch info := entry.(type) {
|
||||
case *files.FolderMetadata:
|
||||
folderInfo = info
|
||||
metadata = &info.Metadata
|
||||
case *files.FileMetadata:
|
||||
fileInfo = info
|
||||
metadata = &info.Metadata
|
||||
default:
|
||||
fs.Errorf(f, "Unknown type %T", entry)
|
||||
continue
|
||||
}
|
||||
|
||||
// Only the last element is reliably cased in PathDisplay
|
||||
entryPath := metadata.PathDisplay
|
||||
leaf := f.opt.Enc.ToStandardName(path.Base(entryPath))
|
||||
remote := path.Join(dir, leaf)
|
||||
if folderInfo != nil {
|
||||
d := fs.NewDir(remote, time.Time{}).SetID(folderInfo.Id)
|
||||
err = list.Add(d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if fileInfo != nil {
|
||||
o, err := f.newObjectWithInfo(ctx, remote, fileInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
o.(*Object).nsID = nsID
|
||||
if o.(*Object).exportType.listable() {
|
||||
err = list.Add(o)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !res.HasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return list.Flush()
|
||||
}
|
||||
|
||||
// findSharedFolder find the id for a given shared folder name
|
||||
// somewhat annoyingly there is no endpoint to query a shared folder by it's name
|
||||
// so our only option is to iterate over all shared folders
|
||||
//
|
||||
// Results are cached for the lifetime of the Fs.
|
||||
func (f *Fs) findSharedFolder(ctx context.Context, name string) (id string, err error) {
|
||||
errFoundFile := errors.New("found file")
|
||||
err = f.listSharedFolders(ctx, func(entry fs.DirEntry) error {
|
||||
if entry.(*fs.Dir).Remote() == name {
|
||||
id = entry.(*fs.Dir).ID()
|
||||
return errFoundFile
|
||||
f.sharedFolderMu.Lock()
|
||||
if f.sharedFolderIDs != nil {
|
||||
if cachedID, ok := f.sharedFolderIDs[name]; ok {
|
||||
f.sharedFolderMu.Unlock()
|
||||
return cachedID, nil
|
||||
}
|
||||
}
|
||||
f.sharedFolderMu.Unlock()
|
||||
|
||||
// Not cached - list all shared folders and populate the cache
|
||||
found := make(map[string]string)
|
||||
err = f.listSharedFolders(ctx, func(entry fs.DirEntry) error {
|
||||
d := entry.(*fs.Dir)
|
||||
found[d.Remote()] = d.ID()
|
||||
return nil
|
||||
})
|
||||
if errors.Is(err, errFoundFile) {
|
||||
return id, nil
|
||||
} else if err != nil {
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return "", fs.ErrorDirNotFound
|
||||
|
||||
f.sharedFolderMu.Lock()
|
||||
f.sharedFolderIDs = found
|
||||
f.sharedFolderMu.Unlock()
|
||||
|
||||
id, ok := found[name]
|
||||
if !ok {
|
||||
return "", fs.ErrorDirNotFound
|
||||
}
|
||||
return id, nil
|
||||
}
|
||||
|
||||
// mountSharedFolder mount a shared folder to the root namespace
|
||||
@@ -1018,99 +1211,34 @@ func (f *Fs) ListP(ctx context.Context, dir string, callback fs.ListRCallback) (
|
||||
return list.Flush()
|
||||
}
|
||||
if f.opt.SharedFolders {
|
||||
err := f.listSharedFolders(ctx, list.Add)
|
||||
if dir == "" {
|
||||
err := f.listSharedFolders(ctx, list.Add)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return list.Flush()
|
||||
}
|
||||
// For subdirectories, use the shared folder's namespace
|
||||
// to list its contents via the files API.
|
||||
firstDir, subDir, _ := strings.Cut(dir, "/")
|
||||
id, err := f.findSharedFolder(ctx, firstDir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return list.Flush()
|
||||
nsCfg := f.cfg.WithNamespaceID(id)
|
||||
nsSrv := files.New(nsCfg)
|
||||
root := ""
|
||||
if subDir != "" {
|
||||
root = "/" + subDir
|
||||
}
|
||||
return f.listDir(ctx, nsSrv, root, dir, id, list)
|
||||
}
|
||||
|
||||
root := f.slashRoot
|
||||
if dir != "" {
|
||||
root += "/" + dir
|
||||
}
|
||||
|
||||
started := false
|
||||
var res *files.ListFolderResult
|
||||
for {
|
||||
if !started {
|
||||
arg := files.NewListFolderArg(f.opt.Enc.FromStandardPath(root))
|
||||
arg.Recursive = false
|
||||
arg.Limit = 1000
|
||||
|
||||
if root == "/" {
|
||||
arg.Path = "" // Specify root folder as empty string
|
||||
}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
res, err = f.srv.ListFolder(arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.ListFolderAPIError:
|
||||
if e.EndpointError != nil && e.EndpointError.Path != nil && e.EndpointError.Path.Tag == files.LookupErrorNotFound {
|
||||
err = fs.ErrorDirNotFound
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
started = true
|
||||
} else {
|
||||
arg := files.ListFolderContinueArg{
|
||||
Cursor: res.Cursor,
|
||||
}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
res, err = f.srv.ListFolderContinue(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("list continue: %w", err)
|
||||
}
|
||||
}
|
||||
for _, entry := range res.Entries {
|
||||
var fileInfo *files.FileMetadata
|
||||
var folderInfo *files.FolderMetadata
|
||||
var metadata *files.Metadata
|
||||
switch info := entry.(type) {
|
||||
case *files.FolderMetadata:
|
||||
folderInfo = info
|
||||
metadata = &info.Metadata
|
||||
case *files.FileMetadata:
|
||||
fileInfo = info
|
||||
metadata = &info.Metadata
|
||||
default:
|
||||
fs.Errorf(f, "Unknown type %T", entry)
|
||||
continue
|
||||
}
|
||||
|
||||
// Only the last element is reliably cased in PathDisplay
|
||||
entryPath := metadata.PathDisplay
|
||||
leaf := f.opt.Enc.ToStandardName(path.Base(entryPath))
|
||||
remote := path.Join(dir, leaf)
|
||||
if folderInfo != nil {
|
||||
d := fs.NewDir(remote, time.Time{}).SetID(folderInfo.Id)
|
||||
err = list.Add(d)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
} else if fileInfo != nil {
|
||||
o, err := f.newObjectWithInfo(ctx, remote, fileInfo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if o.(*Object).exportType.listable() {
|
||||
err = list.Add(o)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if !res.HasMore {
|
||||
break
|
||||
}
|
||||
}
|
||||
return list.Flush()
|
||||
return f.listDir(ctx, f.srv, root, dir, "", list)
|
||||
}
|
||||
|
||||
// Put the object
|
||||
@@ -1119,7 +1247,7 @@ func (f *Fs) ListP(ctx context.Context, dir string, callback fs.ListRCallback) (
|
||||
//
|
||||
// The new object may have been created if an error is returned
|
||||
func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) (fs.Object, error) {
|
||||
if f.opt.SharedFiles || f.opt.SharedFolders {
|
||||
if f.opt.SharedFiles {
|
||||
return nil, errNotSupportedInSharedMode
|
||||
}
|
||||
// Temporary Object under construction
|
||||
@@ -1127,6 +1255,17 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
|
||||
fs: f,
|
||||
remote: src.Remote(),
|
||||
}
|
||||
if f.opt.SharedFolders {
|
||||
firstDir, _, ok := strings.Cut(src.Remote(), "/")
|
||||
if !ok {
|
||||
return nil, errors.New("can't upload to shared folder root")
|
||||
}
|
||||
nsID, err := f.findSharedFolder(ctx, firstDir)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
o.nsID = nsID
|
||||
}
|
||||
return o, o.Update(ctx, in, src, options...)
|
||||
}
|
||||
|
||||
@@ -1137,9 +1276,12 @@ func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, opt
|
||||
|
||||
// Mkdir creates the container if it doesn't exist
|
||||
func (f *Fs) Mkdir(ctx context.Context, dir string) error {
|
||||
if f.opt.SharedFiles || f.opt.SharedFolders {
|
||||
if f.opt.SharedFiles {
|
||||
return errNotSupportedInSharedMode
|
||||
}
|
||||
if f.opt.SharedFolders {
|
||||
return f.mkdirSharedFolder(ctx, dir)
|
||||
}
|
||||
root := path.Join(f.slashRoot, dir)
|
||||
|
||||
// can't create or run metadata on root
|
||||
@@ -1170,6 +1312,48 @@ func (f *Fs) Mkdir(ctx context.Context, dir string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// mkdirSharedFolder creates a directory within a shared folder.
|
||||
// Creating shared folders themselves is not supported.
|
||||
func (f *Fs) mkdirSharedFolder(ctx context.Context, dir string) error {
|
||||
if dir == "" {
|
||||
return nil // root of shared folders listing - nothing to create
|
||||
}
|
||||
if !strings.Contains(dir, "/") {
|
||||
// This is just a shared folder name - it already exists
|
||||
// (you can't create shared folders via the files API)
|
||||
_, err := f.findSharedFolder(ctx, dir)
|
||||
return err
|
||||
}
|
||||
srv, apiPath, _, err := f.sharedFolderSrvAndPath(ctx, dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if apiPath == "" {
|
||||
return nil // root of shared folder already exists
|
||||
}
|
||||
// Check if directory exists by trying to get metadata
|
||||
var entry files.IsMetadata
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
entry, err = srv.GetMetadata(&files.GetMetadataArg{Path: apiPath})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err == nil {
|
||||
if _, ok := entry.(*files.FolderMetadata); ok {
|
||||
return nil // directory exists already
|
||||
}
|
||||
}
|
||||
// Create it
|
||||
arg := files.CreateFolderArg{Path: apiPath}
|
||||
if cErr := checkPathLength(arg.Path); cErr != nil {
|
||||
return cErr
|
||||
}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
_, err = srv.CreateFolderV2(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// purgeCheck removes the root directory, if check is set then it
|
||||
// refuses to do so if it has anything in
|
||||
func (f *Fs) purgeCheck(ctx context.Context, dir string, check bool) (err error) {
|
||||
@@ -1219,12 +1403,73 @@ func (f *Fs) purgeCheck(ctx context.Context, dir string, check bool) (err error)
|
||||
//
|
||||
// Returns an error if it isn't empty
|
||||
func (f *Fs) Rmdir(ctx context.Context, dir string) error {
|
||||
if f.opt.SharedFiles || f.opt.SharedFolders {
|
||||
if f.opt.SharedFiles {
|
||||
return errNotSupportedInSharedMode
|
||||
}
|
||||
if f.opt.SharedFolders {
|
||||
return f.rmdirSharedFolder(ctx, dir)
|
||||
}
|
||||
return f.purgeCheck(ctx, dir, true)
|
||||
}
|
||||
|
||||
// rmdirSharedFolder removes a directory within a shared folder.
|
||||
// Removing the shared folder itself (top-level dir) is not allowed.
|
||||
func (f *Fs) rmdirSharedFolder(ctx context.Context, dir string) error {
|
||||
if dir == "" || !strings.Contains(dir, "/") {
|
||||
return errors.New("can't remove shared folder itself - only subdirectories within it")
|
||||
}
|
||||
return f.purgeCheckSharedFolder(ctx, dir, true)
|
||||
}
|
||||
|
||||
// purgeCheckSharedFolder removes a directory within a shared folder.
|
||||
// If check is true, it verifies the directory is empty first.
|
||||
func (f *Fs) purgeCheckSharedFolder(ctx context.Context, dir string, check bool) error {
|
||||
if dir == "" || !strings.Contains(dir, "/") {
|
||||
return errors.New("can't remove shared folder itself - only subdirectories within it")
|
||||
}
|
||||
srv, apiPath, _, err := f.sharedFolderSrvAndPath(ctx, dir)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if apiPath == "" {
|
||||
return errors.New("can't remove shared folder root")
|
||||
}
|
||||
if check {
|
||||
// Check directory exists
|
||||
var entry files.IsMetadata
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
entry, err = srv.GetMetadata(&files.GetMetadataArg{Path: apiPath})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Rmdir: %w", err)
|
||||
}
|
||||
if _, ok := entry.(*files.FolderMetadata); !ok {
|
||||
return fmt.Errorf("Rmdir: %w", fs.ErrorIsFile)
|
||||
}
|
||||
// Check directory is empty
|
||||
arg := files.NewListFolderArg(apiPath)
|
||||
arg.Recursive = false
|
||||
var res *files.ListFolderResult
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
res, err = srv.ListFolder(arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("Rmdir: %w", err)
|
||||
}
|
||||
if len(res.Entries) != 0 {
|
||||
return errors.New("directory not empty")
|
||||
}
|
||||
}
|
||||
// Remove it
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
_, err = srv.DeleteV2(&files.DeleteArg{Path: apiPath})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
return err
|
||||
}
|
||||
|
||||
// Precision returns the precision
|
||||
func (f *Fs) Precision() time.Duration {
|
||||
return time.Second
|
||||
@@ -1246,6 +1491,10 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Obj
|
||||
return nil, fs.ErrorCantCopy
|
||||
}
|
||||
|
||||
if f.opt.SharedFolders {
|
||||
return f.copySharedFolder(ctx, srcObj, remote)
|
||||
}
|
||||
|
||||
// Find and remove existing object
|
||||
cleanup, err := operations.RemoveExisting(ctx, f, remote, "server side copy")
|
||||
if err != nil {
|
||||
@@ -1288,12 +1537,76 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Obj
|
||||
return dstObj, nil
|
||||
}
|
||||
|
||||
// copySharedFolder copies an object within shared folders.
|
||||
// Both source and destination must be in the same shared folder namespace.
|
||||
func (f *Fs) copySharedFolder(ctx context.Context, srcObj *Object, remote string) (fs.Object, error) {
|
||||
srcFirstDir, _, _ := strings.Cut(srcObj.remote, "/")
|
||||
dstFirstDir, _, ok := strings.Cut(remote, "/")
|
||||
if !ok {
|
||||
return nil, fs.ErrorCantCopy
|
||||
}
|
||||
srcNsID, err := f.findSharedFolder(ctx, srcFirstDir)
|
||||
if err != nil {
|
||||
return nil, fs.ErrorCantCopy
|
||||
}
|
||||
dstNsID, err := f.findSharedFolder(ctx, dstFirstDir)
|
||||
if err != nil {
|
||||
return nil, fs.ErrorCantCopy
|
||||
}
|
||||
if srcNsID != dstNsID {
|
||||
return nil, fs.ErrorCantCopy
|
||||
}
|
||||
srv := files.New(f.cfg.WithNamespaceID(srcNsID))
|
||||
|
||||
// Find and remove existing object
|
||||
cleanup, err := operations.RemoveExisting(ctx, f, remote, "server side copy")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer cleanup(&err)
|
||||
|
||||
dstObj := &Object{
|
||||
fs: f,
|
||||
remote: remote,
|
||||
nsID: srcNsID,
|
||||
}
|
||||
|
||||
_, srcSubPath, _ := strings.Cut(srcObj.remote, "/")
|
||||
_, dstSubPath, _ := strings.Cut(remote, "/")
|
||||
arg := files.RelocationArg{
|
||||
RelocationPath: files.RelocationPath{
|
||||
FromPath: f.opt.Enc.FromStandardPath("/" + srcSubPath),
|
||||
ToPath: f.opt.Enc.FromStandardPath("/" + dstSubPath),
|
||||
},
|
||||
}
|
||||
var result *files.RelocationResult
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
result, err = srv.CopyV2(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("copy failed: %w", err)
|
||||
}
|
||||
fileInfo, ok := result.Metadata.(*files.FileMetadata)
|
||||
if !ok {
|
||||
return nil, fs.ErrorNotAFile
|
||||
}
|
||||
err = dstObj.setMetadataFromEntry(fileInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("copy failed: %w", err)
|
||||
}
|
||||
return dstObj, nil
|
||||
}
|
||||
|
||||
// Purge deletes all the files and the container
|
||||
//
|
||||
// Optional interface: Only implement this if you have a way of
|
||||
// deleting all the files quicker than just running Remove() on the
|
||||
// result of List()
|
||||
func (f *Fs) Purge(ctx context.Context, dir string) (err error) {
|
||||
if f.opt.SharedFolders {
|
||||
return f.purgeCheckSharedFolder(ctx, dir, false)
|
||||
}
|
||||
return f.purgeCheck(ctx, dir, false)
|
||||
}
|
||||
|
||||
@@ -1313,6 +1626,10 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
|
||||
if f.opt.SharedFolders {
|
||||
return f.moveSharedFolder(ctx, srcObj, remote)
|
||||
}
|
||||
|
||||
// Temporary Object under construction
|
||||
dstObj := &Object{
|
||||
fs: f,
|
||||
@@ -1358,6 +1675,67 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
||||
return dstObj, nil
|
||||
}
|
||||
|
||||
// moveSharedFolder moves an object within shared folders.
|
||||
// Both source and destination must be in the same shared folder namespace.
|
||||
func (f *Fs) moveSharedFolder(ctx context.Context, srcObj *Object, remote string) (fs.Object, error) {
|
||||
srcFirstDir, _, _ := strings.Cut(srcObj.remote, "/")
|
||||
dstFirstDir, _, ok := strings.Cut(remote, "/")
|
||||
if !ok {
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
srcNsID, err := f.findSharedFolder(ctx, srcFirstDir)
|
||||
if err != nil {
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
dstNsID, err := f.findSharedFolder(ctx, dstFirstDir)
|
||||
if err != nil {
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
if srcNsID != dstNsID {
|
||||
return nil, fs.ErrorCantMove
|
||||
}
|
||||
srv := files.New(f.cfg.WithNamespaceID(srcNsID))
|
||||
|
||||
dstObj := &Object{
|
||||
fs: f,
|
||||
remote: remote,
|
||||
nsID: srcNsID,
|
||||
}
|
||||
|
||||
_, srcSubPath, _ := strings.Cut(srcObj.remote, "/")
|
||||
_, dstSubPath, _ := strings.Cut(remote, "/")
|
||||
arg := files.RelocationArg{
|
||||
RelocationPath: files.RelocationPath{
|
||||
FromPath: f.opt.Enc.FromStandardPath("/" + srcSubPath),
|
||||
ToPath: f.opt.Enc.FromStandardPath("/" + dstSubPath),
|
||||
},
|
||||
}
|
||||
var result *files.RelocationResult
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
result, err = srv.MoveV2(&arg)
|
||||
switch e := err.(type) {
|
||||
case files.MoveV2APIError:
|
||||
if e.EndpointError != nil && e.EndpointError.FromLookup != nil && e.EndpointError.FromLookup.Tag == files.LookupErrorNotFound {
|
||||
fs.Debugf(srcObj, "Retrying move on %v error", err)
|
||||
return true, err
|
||||
}
|
||||
}
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("move failed: %w", err)
|
||||
}
|
||||
fileInfo, ok := result.Metadata.(*files.FileMetadata)
|
||||
if !ok {
|
||||
return nil, fs.ErrorNotAFile
|
||||
}
|
||||
err = dstObj.setMetadataFromEntry(fileInfo)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("move failed: %w", err)
|
||||
}
|
||||
return dstObj, nil
|
||||
}
|
||||
|
||||
// PublicLink adds a "readable by anyone with link" permission on the given file or folder.
|
||||
func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration, unlink bool) (link string, err error) {
|
||||
absPath := f.opt.Enc.FromStandardPath(path.Join(f.slashRoot, remote))
|
||||
@@ -1445,6 +1823,11 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
||||
fs.Debugf(srcFs, "Can't move directory - not same remote type")
|
||||
return fs.ErrorCantDirMove
|
||||
}
|
||||
|
||||
if f.opt.SharedFolders {
|
||||
return f.dirMoveSharedFolder(ctx, srcFs, srcRemote, dstRemote)
|
||||
}
|
||||
|
||||
srcPath := path.Join(srcFs.slashRoot, srcRemote)
|
||||
dstPath := path.Join(f.slashRoot, dstRemote)
|
||||
|
||||
@@ -1477,6 +1860,57 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
||||
return nil
|
||||
}
|
||||
|
||||
// dirMoveSharedFolder moves a directory within shared folders.
|
||||
// Both source and destination must be in the same shared folder namespace.
|
||||
func (f *Fs) dirMoveSharedFolder(ctx context.Context, srcFs *Fs, srcRemote, dstRemote string) error {
|
||||
srcFirstDir, srcSubPath, _ := strings.Cut(srcRemote, "/")
|
||||
dstFirstDir, dstSubPath, _ := strings.Cut(dstRemote, "/")
|
||||
if srcSubPath == "" || dstSubPath == "" {
|
||||
return errors.New("can't move shared folder itself - only subdirectories within it")
|
||||
}
|
||||
srcNsID, err := srcFs.findSharedFolder(ctx, srcFirstDir)
|
||||
if err != nil {
|
||||
return fs.ErrorCantDirMove
|
||||
}
|
||||
dstNsID, err := f.findSharedFolder(ctx, dstFirstDir)
|
||||
if err != nil {
|
||||
return fs.ErrorCantDirMove
|
||||
}
|
||||
if srcNsID != dstNsID {
|
||||
return fs.ErrorCantDirMove
|
||||
}
|
||||
srv := files.New(f.cfg.WithNamespaceID(srcNsID))
|
||||
|
||||
// Check if destination exists
|
||||
dstAPIPath := f.opt.Enc.FromStandardPath("/" + dstSubPath)
|
||||
var entry files.IsMetadata
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
entry, err = srv.GetMetadata(&files.GetMetadataArg{Path: dstAPIPath})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err == nil {
|
||||
if _, ok := entry.(*files.FolderMetadata); ok {
|
||||
return fs.ErrorDirExists
|
||||
}
|
||||
}
|
||||
|
||||
// Do the move
|
||||
arg := files.RelocationArg{
|
||||
RelocationPath: files.RelocationPath{
|
||||
FromPath: f.opt.Enc.FromStandardPath("/" + srcSubPath),
|
||||
ToPath: dstAPIPath,
|
||||
},
|
||||
}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
_, err = srv.MoveV2(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("MoveDir failed: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// About gets quota information
|
||||
func (f *Fs) About(ctx context.Context) (usage *fs.Usage, err error) {
|
||||
var q *users.SpaceUsage
|
||||
@@ -1741,7 +2175,7 @@ func (o *Object) ID() string {
|
||||
|
||||
// Hash returns the dropbox special hash
|
||||
func (o *Object) Hash(ctx context.Context, t hash.Type) (string, error) {
|
||||
if o.fs.opt.SharedFiles || o.fs.opt.SharedFolders {
|
||||
if o.fs.opt.SharedFiles {
|
||||
return "", errNotSupportedInSharedMode
|
||||
}
|
||||
if t != DbHashType {
|
||||
@@ -1802,6 +2236,29 @@ func (o *Object) setMetadataFromEntry(info *files.FileMetadata) error {
|
||||
|
||||
// Reads the entry for a file from dropbox
|
||||
func (o *Object) readEntry(ctx context.Context) (*files.FileMetadata, error) {
|
||||
if o.nsID != "" {
|
||||
srv := o.fileSrv()
|
||||
var entry files.IsMetadata
|
||||
var err error
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
entry, err = srv.GetMetadata(&files.GetMetadataArg{Path: o.nsPath()})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
switch e := err.(type) {
|
||||
case files.GetMetadataAPIError:
|
||||
if e.EndpointError != nil && e.EndpointError.Path != nil && e.EndpointError.Path.Tag == files.LookupErrorNotFound {
|
||||
return nil, fs.ErrorObjectNotFound
|
||||
}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
fileInfo, ok := entry.(*files.FileMetadata)
|
||||
if !ok {
|
||||
return nil, fs.ErrorNotAFile
|
||||
}
|
||||
return fileInfo, nil
|
||||
}
|
||||
return o.fs.getFileMetadata(ctx, o.remotePath())
|
||||
}
|
||||
|
||||
@@ -1868,8 +2325,9 @@ func (o *Object) export(ctx context.Context) (in io.ReadCloser, err error) {
|
||||
|
||||
arg := files.ExportArg{Path: o.id, ExportFormat: string(o.exportAPIFormat)}
|
||||
var exportResult *files.ExportResult
|
||||
srv := o.fileSrv()
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
exportResult, in, err = o.fs.srv.Export(&arg)
|
||||
exportResult, in, err = srv.Export(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1910,8 +2368,9 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
||||
Path: o.id,
|
||||
ExtraHeaders: headers,
|
||||
}
|
||||
srv := o.fileSrv()
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
_, in, err = o.fs.srv.Download(&arg)
|
||||
_, in, err = srv.Download(&arg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
|
||||
@@ -1931,11 +2390,11 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
||||
// Will introduce two additional network requests to start and finish the session.
|
||||
// If the size is unknown (i.e. -1) the method incurs one additional
|
||||
// request to the Dropbox API that does not carry a payload to close the append session.
|
||||
func (o *Object) uploadChunked(ctx context.Context, in0 io.Reader, commitInfo *files.CommitInfo, size int64) (entry *files.FileMetadata, err error) {
|
||||
func (o *Object) uploadChunked(ctx context.Context, in0 io.Reader, srv files.Client, commitInfo *files.CommitInfo, size int64, useBatching bool) (entry *files.FileMetadata, err error) {
|
||||
// start upload
|
||||
var res *files.UploadSessionStartResult
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
res, err = o.fs.srv.UploadSessionStart(&files.UploadSessionStartArg{}, nil)
|
||||
res, err = srv.UploadSessionStart(&files.UploadSessionStartArg{}, nil)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
@@ -1972,7 +2431,7 @@ func (o *Object) uploadChunked(ctx context.Context, in0 io.Reader, commitInfo *f
|
||||
if _, err = chunk.Seek(skip, io.SeekStart); err != nil {
|
||||
return false, err
|
||||
}
|
||||
err = o.fs.srv.UploadSessionAppendV2(&appendArg, chunk)
|
||||
err = srv.UploadSessionAppendV2(&appendArg, chunk)
|
||||
// after session is started, we retry everything
|
||||
if err != nil {
|
||||
// Check for incorrect offset error and retry with new offset
|
||||
@@ -2026,12 +2485,12 @@ func (o *Object) uploadChunked(ctx context.Context, in0 io.Reader, commitInfo *f
|
||||
}
|
||||
// If we are batching then we should have written all the data now
|
||||
// store the commit info now for a batch commit
|
||||
if o.fs.batcher.Batching() {
|
||||
if useBatching {
|
||||
return o.fs.batcher.Commit(ctx, o.remote, args)
|
||||
}
|
||||
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
entry, err = o.fs.srv.UploadSessionFinish(args, nil)
|
||||
entry, err = srv.UploadSessionFinish(args, nil)
|
||||
if retry, err := shouldRetryExclude(ctx, err); !retry {
|
||||
return retry, err
|
||||
}
|
||||
@@ -2075,14 +2534,15 @@ func checkPathLength(name string) (err error) {
|
||||
//
|
||||
// The new object may have been created if an error is returned
|
||||
func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, options ...fs.OpenOption) error {
|
||||
if o.fs.opt.SharedFiles || o.fs.opt.SharedFolders {
|
||||
if o.fs.opt.SharedFiles {
|
||||
return errNotSupportedInSharedMode
|
||||
}
|
||||
uploadPath := o.nsPath()
|
||||
remote := o.remotePath()
|
||||
if ignoredFiles.MatchString(remote) {
|
||||
return fserrors.NoRetryError(fmt.Errorf("file name %q is disallowed - not uploading", path.Base(remote)))
|
||||
}
|
||||
commitInfo := files.NewCommitInfo(o.fs.opt.Enc.FromStandardPath(o.remotePath()))
|
||||
commitInfo := files.NewCommitInfo(uploadPath)
|
||||
commitInfo.Mode.Tag = "overwrite"
|
||||
// The Dropbox API only accepts timestamps in UTC with second precision.
|
||||
clientModified := src.ModTime(ctx).UTC().Round(time.Second)
|
||||
@@ -2092,14 +2552,17 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||
return cErr
|
||||
}
|
||||
|
||||
srv := o.fileSrv()
|
||||
size := src.Size()
|
||||
// Disable batching for shared folder objects since the batch commit uses f.srv
|
||||
useBatching := o.fs.batcher.Batching() && o.nsID == ""
|
||||
var err error
|
||||
var entry *files.FileMetadata
|
||||
if size > int64(o.fs.opt.ChunkSize) || size < 0 || o.fs.batcher.Batching() {
|
||||
entry, err = o.uploadChunked(ctx, in, commitInfo, size)
|
||||
if size > int64(o.fs.opt.ChunkSize) || size < 0 || useBatching {
|
||||
entry, err = o.uploadChunked(ctx, in, srv, commitInfo, size, useBatching)
|
||||
} else {
|
||||
err = o.fs.pacer.CallNoRetry(func() (bool, error) {
|
||||
entry, err = o.fs.srv.Upload(&files.UploadArg{CommitInfo: *commitInfo}, in)
|
||||
entry, err = srv.Upload(&files.UploadArg{CommitInfo: *commitInfo}, in)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
}
|
||||
@@ -2120,12 +2583,13 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
||||
|
||||
// Remove an object
|
||||
func (o *Object) Remove(ctx context.Context) (err error) {
|
||||
if o.fs.opt.SharedFiles || o.fs.opt.SharedFolders {
|
||||
if o.fs.opt.SharedFiles {
|
||||
return errNotSupportedInSharedMode
|
||||
}
|
||||
srv := o.fileSrv()
|
||||
err = o.fs.pacer.Call(func() (bool, error) {
|
||||
_, err = o.fs.srv.DeleteV2(&files.DeleteArg{
|
||||
Path: o.fs.opt.Enc.FromStandardPath(o.remotePath()),
|
||||
_, err = srv.DeleteV2(&files.DeleteArg{
|
||||
Path: o.nsPath(),
|
||||
})
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
package dropbox
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"io"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox"
|
||||
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/async"
|
||||
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/files"
|
||||
"github.com/dropbox/dropbox-sdk-go-unofficial/v6/dropbox/sharing"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/object"
|
||||
"github.com/rclone/rclone/fstest/fstests"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
@@ -95,8 +101,310 @@ func (f *Fs) InternalTestPaperExport(t *testing.T) {
|
||||
require.Contains(t, text, excerpt)
|
||||
}
|
||||
}
|
||||
|
||||
// InternalTestSharedFolder tests both read and write operations on shared folders.
|
||||
// It uses a single shared folder setup to avoid re-sharing between subtests
|
||||
// (Dropbox has eventual consistency issues with share/unshare cycles).
|
||||
func (f *Fs) InternalTestSharedFolder(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
testDir := f.slashRoot
|
||||
|
||||
// Share the test root folder
|
||||
folderName := f.opt.Enc.ToStandardName(strings.TrimPrefix(testDir, "/"))
|
||||
shareArg := sharing.NewShareFolderArg(testDir)
|
||||
var sharedFolderID string
|
||||
var shareLaunch *sharing.ShareFolderLaunch
|
||||
var err error
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
shareLaunch, err = f.sharing.ShareFolder(shareArg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
if err != nil {
|
||||
sharedFolderID, err = f.findSharedFolder(ctx, folderName)
|
||||
require.NoError(t, err, "ShareFolder failed and couldn't find existing share")
|
||||
} else {
|
||||
switch shareLaunch.Tag {
|
||||
case sharing.ShareFolderLaunchComplete:
|
||||
sharedFolderID = shareLaunch.Complete.SharedFolderId
|
||||
case sharing.ShareFolderLaunchAsyncJobId:
|
||||
pollArg := async.PollArg{AsyncJobId: shareLaunch.AsyncJobId}
|
||||
for range 30 {
|
||||
time.Sleep(time.Second)
|
||||
var status *sharing.ShareFolderJobStatus
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
status, err = f.sharing.CheckShareJobStatus(&pollArg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
if status.Tag == sharing.ShareFolderJobStatusComplete {
|
||||
sharedFolderID = status.Complete.SharedFolderId
|
||||
break
|
||||
}
|
||||
}
|
||||
require.NotEmpty(t, sharedFolderID, "share folder job did not complete")
|
||||
}
|
||||
}
|
||||
require.NotEmpty(t, sharedFolderID)
|
||||
|
||||
defer func() {
|
||||
unshareArg := sharing.NewUnshareFolderArg(sharedFolderID)
|
||||
unshareArg.LeaveACopy = true
|
||||
_ = f.pacer.Call(func() (bool, error) {
|
||||
_, err = f.sharing.UnshareFolder(unshareArg)
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
}()
|
||||
|
||||
sf := *f //nolint:govet // intentional copy; mutex is zero-valued and unused before this point
|
||||
sf.opt.SharedFolders = true
|
||||
sf.features = (&fs.Features{
|
||||
CaseInsensitive: true,
|
||||
ReadMimeType: false,
|
||||
CanHaveEmptyDirectories: true,
|
||||
}).Fill(ctx, &sf)
|
||||
sharedFs := &sf
|
||||
|
||||
// Upload a test file using the normal API for listing tests
|
||||
testFileName := "shared-folder-test-file.txt"
|
||||
testFilePath := testDir + "/" + testFileName
|
||||
content := "hello shared folder"
|
||||
uploadArg := files.NewUploadArg(testFilePath)
|
||||
uploadArg.Mode = &files.WriteMode{Tagged: dropbox.Tagged{Tag: files.WriteModeOverwrite}}
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
_, err = f.srv.Upload(uploadArg, strings.NewReader(content))
|
||||
return shouldRetry(ctx, err)
|
||||
})
|
||||
require.NoError(t, err)
|
||||
defer func() {
|
||||
_, _ = f.srv.DeleteV2(files.NewDeleteArg(testFilePath))
|
||||
}()
|
||||
|
||||
t.Run("List", func(t *testing.T) {
|
||||
// listing root should include the shared folder
|
||||
var rootEntries fs.DirEntries
|
||||
err = sharedFs.ListP(ctx, "", func(entries fs.DirEntries) error {
|
||||
rootEntries = append(rootEntries, entries...)
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
found := false
|
||||
for _, entry := range rootEntries {
|
||||
if entry.Remote() == folderName {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, found, "shared folder %q not found in root listing (have %v)", folderName, rootEntries)
|
||||
|
||||
// listing the shared folder should show its contents
|
||||
var dirEntries fs.DirEntries
|
||||
err = sharedFs.ListP(ctx, folderName, func(entries fs.DirEntries) error {
|
||||
dirEntries = append(dirEntries, entries...)
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
foundFile := false
|
||||
expectedRemote := folderName + "/" + testFileName
|
||||
for _, entry := range dirEntries {
|
||||
if entry.Remote() == expectedRemote {
|
||||
foundFile = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, foundFile, "file %q not found in shared folder listing (have %v)", expectedRemote, dirEntries)
|
||||
})
|
||||
|
||||
t.Run("NewObject", func(t *testing.T) {
|
||||
expectedRemote := folderName + "/" + testFileName
|
||||
obj, err := sharedFs.NewObject(ctx, expectedRemote)
|
||||
require.NoError(t, err, "NewObject failed for shared folder file")
|
||||
assert.Equal(t, expectedRemote, obj.Remote())
|
||||
assert.Equal(t, int64(len(content)), obj.Size())
|
||||
})
|
||||
|
||||
t.Run("Open", func(t *testing.T) {
|
||||
expectedRemote := folderName + "/" + testFileName
|
||||
obj, err := sharedFs.NewObject(ctx, expectedRemote)
|
||||
require.NoError(t, err)
|
||||
rc, err := obj.Open(ctx)
|
||||
require.NoError(t, err, "Open failed for shared folder file")
|
||||
buf, err := io.ReadAll(rc)
|
||||
require.NoError(t, rc.Close())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, content, string(buf))
|
||||
})
|
||||
|
||||
t.Run("Put", func(t *testing.T) {
|
||||
// Upload a file via Put
|
||||
content := "hello from shared folder put"
|
||||
remote := folderName + "/test-put-file.txt"
|
||||
src := object.NewStaticObjectInfo(remote, time.Now(), int64(len(content)), true, nil, nil)
|
||||
obj, err := sharedFs.Put(ctx, bytes.NewReader([]byte(content)), src)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, remote, obj.Remote())
|
||||
assert.Equal(t, int64(len(content)), obj.Size())
|
||||
|
||||
// Verify we can read back the content
|
||||
rc, err := obj.Open(ctx)
|
||||
require.NoError(t, err)
|
||||
buf, err := io.ReadAll(rc)
|
||||
require.NoError(t, rc.Close())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, content, string(buf))
|
||||
|
||||
// Clean up
|
||||
require.NoError(t, obj.Remove(ctx))
|
||||
})
|
||||
|
||||
t.Run("Hash", func(t *testing.T) {
|
||||
// Upload a file and check its hash
|
||||
content := "hash test content"
|
||||
remote := folderName + "/test-hash-file.txt"
|
||||
src := object.NewStaticObjectInfo(remote, time.Now(), int64(len(content)), true, nil, nil)
|
||||
obj, err := sharedFs.Put(ctx, bytes.NewReader([]byte(content)), src)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = obj.Remove(ctx) }()
|
||||
|
||||
hash, err := obj.Hash(ctx, DbHashType)
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, hash, "hash should not be empty")
|
||||
})
|
||||
|
||||
t.Run("Mkdir", func(t *testing.T) {
|
||||
// Create a subdirectory within the shared folder
|
||||
subDir := folderName + "/test-mkdir-subdir"
|
||||
err := sharedFs.Mkdir(ctx, subDir)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify it appears in the listing
|
||||
var entries fs.DirEntries
|
||||
err = sharedFs.ListP(ctx, folderName, func(e fs.DirEntries) error {
|
||||
entries = append(entries, e...)
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
found := false
|
||||
for _, entry := range entries {
|
||||
if entry.Remote() == subDir {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
assert.True(t, found, "subdirectory %q not found in listing", subDir)
|
||||
|
||||
// Clean up
|
||||
require.NoError(t, sharedFs.Rmdir(ctx, subDir))
|
||||
})
|
||||
|
||||
t.Run("Rmdir", func(t *testing.T) {
|
||||
// Create and then remove a subdirectory
|
||||
subDir := folderName + "/test-rmdir-subdir"
|
||||
require.NoError(t, sharedFs.Mkdir(ctx, subDir))
|
||||
require.NoError(t, sharedFs.Rmdir(ctx, subDir))
|
||||
|
||||
// Verify it's gone
|
||||
var entries fs.DirEntries
|
||||
err := sharedFs.ListP(ctx, folderName, func(e fs.DirEntries) error {
|
||||
entries = append(entries, e...)
|
||||
return nil
|
||||
})
|
||||
require.NoError(t, err)
|
||||
for _, entry := range entries {
|
||||
assert.NotEqual(t, subDir, entry.Remote(), "subdirectory should have been removed")
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("RmdirSharedFolderRoot", func(t *testing.T) {
|
||||
// Removing a shared folder itself should fail
|
||||
err := sharedFs.Rmdir(ctx, folderName)
|
||||
assert.Error(t, err, "should not be able to remove shared folder itself")
|
||||
})
|
||||
|
||||
t.Run("Remove", func(t *testing.T) {
|
||||
// Upload and then delete a file
|
||||
content := "file to remove"
|
||||
remote := folderName + "/test-remove-file.txt"
|
||||
src := object.NewStaticObjectInfo(remote, time.Now(), int64(len(content)), true, nil, nil)
|
||||
obj, err := sharedFs.Put(ctx, bytes.NewReader([]byte(content)), src)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = obj.Remove(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Verify it's gone
|
||||
_, err = sharedFs.NewObject(ctx, remote)
|
||||
assert.ErrorIs(t, err, fs.ErrorObjectNotFound)
|
||||
})
|
||||
|
||||
t.Run("Copy", func(t *testing.T) {
|
||||
// Upload a file, then server-side copy it within the same shared folder
|
||||
content := "file to copy"
|
||||
srcRemote := folderName + "/test-copy-src.txt"
|
||||
dstRemote := folderName + "/test-copy-dst.txt"
|
||||
|
||||
src := object.NewStaticObjectInfo(srcRemote, time.Now(), int64(len(content)), true, nil, nil)
|
||||
srcObj, err := sharedFs.Put(ctx, bytes.NewReader([]byte(content)), src)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = srcObj.Remove(ctx) }()
|
||||
|
||||
dstObj, err := sharedFs.Copy(ctx, srcObj, dstRemote)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = dstObj.Remove(ctx) }()
|
||||
|
||||
assert.Equal(t, dstRemote, dstObj.Remote())
|
||||
assert.Equal(t, int64(len(content)), dstObj.Size())
|
||||
|
||||
// Verify content
|
||||
rc, err := dstObj.Open(ctx)
|
||||
require.NoError(t, err)
|
||||
buf, err := io.ReadAll(rc)
|
||||
require.NoError(t, rc.Close())
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, content, string(buf))
|
||||
})
|
||||
|
||||
t.Run("Move", func(t *testing.T) {
|
||||
// Upload a file, then server-side move it within the same shared folder
|
||||
content := "file to move"
|
||||
srcRemote := folderName + "/test-move-src.txt"
|
||||
dstRemote := folderName + "/test-move-dst.txt"
|
||||
|
||||
src := object.NewStaticObjectInfo(srcRemote, time.Now(), int64(len(content)), true, nil, nil)
|
||||
srcObj, err := sharedFs.Put(ctx, bytes.NewReader([]byte(content)), src)
|
||||
require.NoError(t, err)
|
||||
|
||||
dstObj, err := sharedFs.Move(ctx, srcObj, dstRemote)
|
||||
require.NoError(t, err)
|
||||
defer func() { _ = dstObj.Remove(ctx) }()
|
||||
|
||||
assert.Equal(t, dstRemote, dstObj.Remote())
|
||||
|
||||
// Source should be gone
|
||||
_, err = sharedFs.NewObject(ctx, srcRemote)
|
||||
assert.ErrorIs(t, err, fs.ErrorObjectNotFound)
|
||||
})
|
||||
|
||||
t.Run("Purge", func(t *testing.T) {
|
||||
// Create a subdir with a file, then purge
|
||||
subDir := folderName + "/test-purge-subdir"
|
||||
require.NoError(t, sharedFs.Mkdir(ctx, subDir))
|
||||
|
||||
content := "file in purge dir"
|
||||
remote := subDir + "/file.txt"
|
||||
src := object.NewStaticObjectInfo(remote, time.Now(), int64(len(content)), true, nil, nil)
|
||||
_, err := sharedFs.Put(ctx, bytes.NewReader([]byte(content)), src)
|
||||
require.NoError(t, err)
|
||||
|
||||
err = sharedFs.Purge(ctx, subDir)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func (f *Fs) InternalTest(t *testing.T) {
|
||||
t.Run("PaperExport", f.InternalTestPaperExport)
|
||||
t.Run("SharedFolder", f.InternalTestSharedFolder)
|
||||
}
|
||||
|
||||
var _ fstests.InternalTester = (*Fs)(nil)
|
||||
@@ -118,19 +118,12 @@ func (c *Client) Authenticate(ctx context.Context) error {
|
||||
|
||||
fs.Debugf("icloud", "Authenticating as %s\n", c.appleID)
|
||||
err := c.Session.SignIn(ctx, c.appleID, c.password)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// If 2FA is required, don't try AuthWithToken yet — the caller
|
||||
// must complete 2FA first, then call AuthWithToken.
|
||||
if c.Session.Requires2FA() {
|
||||
return nil
|
||||
}
|
||||
|
||||
err = c.Session.AuthWithToken(ctx)
|
||||
if err == nil && c.sessionSaveCallback != nil {
|
||||
c.sessionSaveCallback(c.Session)
|
||||
if err == nil {
|
||||
err = c.Session.AuthWithToken(ctx)
|
||||
if err == nil && c.sessionSaveCallback != nil {
|
||||
c.sessionSaveCallback(c.Session)
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
@@ -10,15 +9,11 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/oracle/oci-go-sdk/v65/common"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/rclone/rclone/fs/fshttp"
|
||||
"github.com/rclone/rclone/lib/rest"
|
||||
)
|
||||
|
||||
const iCloudUserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.3.1 Safari/605.1.15"
|
||||
|
||||
// Session represents an iCloud session
|
||||
type Session struct {
|
||||
SessionToken string `json:"session_token"`
|
||||
@@ -27,22 +22,10 @@ type Session struct {
|
||||
AccountCountry string `json:"account_country"`
|
||||
TrustToken string `json:"trust_token"`
|
||||
ClientID string `json:"client_id"`
|
||||
AuthAttributes string `json:"auth_attributes"`
|
||||
FrameID string `json:"frame_id"`
|
||||
Cookies []*http.Cookie `json:"cookies"`
|
||||
AccountInfo AccountInfo `json:"account_info"`
|
||||
|
||||
srv *rest.Client `json:"-"`
|
||||
needs2FA bool `json:"-"` // set when SRP signin returns 409
|
||||
}
|
||||
|
||||
// srpInitResponse is the server response from /auth/signin/init
|
||||
type srpInitResponse struct {
|
||||
Iteration int `json:"iteration"`
|
||||
Salt string `json:"salt"`
|
||||
Protocol string `json:"protocol"`
|
||||
B string `json:"b"`
|
||||
C string `json:"c"`
|
||||
srv *rest.Client `json:"-"`
|
||||
}
|
||||
|
||||
// String returns the session as a string
|
||||
@@ -74,222 +57,24 @@ func (s *Session) Request(ctx context.Context, opts rest.Opts, request any, resp
|
||||
if val := resp.Header.Get("scnt"); val != "" {
|
||||
s.Scnt = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-Auth-Attributes"); val != "" {
|
||||
s.AuthAttributes = val
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// Requires2FA returns true if the session requires 2FA
|
||||
func (s *Session) Requires2FA() bool {
|
||||
if s.needs2FA {
|
||||
return true
|
||||
}
|
||||
return s.AccountInfo.DsInfo != nil && s.AccountInfo.DsInfo.HsaVersion == 2 && s.AccountInfo.HsaChallengeRequired
|
||||
return s.AccountInfo.DsInfo.HsaVersion == 2 && s.AccountInfo.HsaChallengeRequired
|
||||
}
|
||||
|
||||
// SignIn performs SRP-based authentication against Apple's idmsa endpoint.
|
||||
// SignIn signs in the session
|
||||
func (s *Session) SignIn(ctx context.Context, appleID, password string) error {
|
||||
// Apple's SRP implementation expects a lowercase account name.
|
||||
// The old plaintext flow didn't need this because the server normalized
|
||||
// it, but SRP uses the username in client-side proof computation (M1).
|
||||
appleID = strings.ToLower(appleID)
|
||||
|
||||
// Step 1: Initialize the auth session
|
||||
if err := s.authStart(ctx); err != nil {
|
||||
return fmt.Errorf("authStart: %w", err)
|
||||
}
|
||||
|
||||
// Step 2: Federate (submit account name)
|
||||
if err := s.authFederate(ctx, appleID); err != nil {
|
||||
return fmt.Errorf("authFederate: %w", err)
|
||||
}
|
||||
|
||||
// Step 3: SRP init — send client public value A, get salt + B
|
||||
client := newSRPClient()
|
||||
aBase64 := base64.StdEncoding.EncodeToString(client.getABytes())
|
||||
|
||||
initResp, err := s.authSRPInit(ctx, aBase64, appleID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("authSRPInit: %w", err)
|
||||
}
|
||||
|
||||
// Decode server values
|
||||
serverB, err := base64.StdEncoding.DecodeString(initResp.B)
|
||||
if err != nil {
|
||||
return fmt.Errorf("decode B: %w", err)
|
||||
}
|
||||
salt, err := base64.StdEncoding.DecodeString(initResp.Salt)
|
||||
if err != nil {
|
||||
return fmt.Errorf("decode salt: %w", err)
|
||||
}
|
||||
|
||||
// Step 4: Derive password key and process the SRP challenge
|
||||
derivedKey, err := derivePassword(password, salt, initResp.Iteration, initResp.Protocol)
|
||||
if err != nil {
|
||||
return fmt.Errorf("derivePassword: %w", err)
|
||||
}
|
||||
client.processChallenge([]byte(appleID), derivedKey, salt, serverB)
|
||||
|
||||
// Step 5: Complete — send M1, M2 proofs
|
||||
m1Base64 := base64.StdEncoding.EncodeToString(client.M1)
|
||||
m2Base64 := base64.StdEncoding.EncodeToString(client.M2)
|
||||
|
||||
if err := s.authSRPComplete(ctx, appleID, m1Base64, m2Base64, initResp.C); err != nil {
|
||||
return fmt.Errorf("authSRPComplete: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// authStart initializes the SRP auth session by hitting the authorize/signin endpoint.
|
||||
func (s *Session) authStart(ctx context.Context) error {
|
||||
if s.FrameID == "" {
|
||||
s.FrameID = strings.ToLower(uuid.New().String())
|
||||
}
|
||||
frameTag := "auth-" + s.FrameID
|
||||
|
||||
params := url.Values{}
|
||||
params.Set("frame_id", frameTag)
|
||||
params.Set("language", "en_US")
|
||||
params.Set("skVersion", "7")
|
||||
params.Set("iframeId", frameTag)
|
||||
params.Set("client_id", s.ClientID)
|
||||
params.Set("redirect_uri", "https://www.icloud.com")
|
||||
params.Set("response_type", "code")
|
||||
params.Set("response_mode", "web_message")
|
||||
params.Set("state", frameTag)
|
||||
params.Set("authVersion", "latest")
|
||||
|
||||
opts := rest.Opts{
|
||||
Method: "GET",
|
||||
Path: "/authorize/signin",
|
||||
Parameters: params,
|
||||
ExtraHeaders: map[string]string{
|
||||
"Accept": "*/*",
|
||||
"User-Agent": iCloudUserAgent,
|
||||
},
|
||||
RootURL: authEndpoint,
|
||||
NoResponse: true,
|
||||
}
|
||||
|
||||
resp, err := s.srv.Call(ctx, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("authStart: unexpected status %s", resp.Status)
|
||||
}
|
||||
|
||||
if val := resp.Header.Get("X-Apple-Auth-Attributes"); val != "" {
|
||||
s.AuthAttributes = val
|
||||
}
|
||||
if val := resp.Header.Get("scnt"); val != "" {
|
||||
s.Scnt = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-ID-Session-Id"); val != "" {
|
||||
s.SessionID = val
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// authFederate submits the account name to Apple's federate endpoint.
|
||||
func (s *Session) authFederate(ctx context.Context, accountName string) error {
|
||||
values := map[string]any{
|
||||
"accountName": accountName,
|
||||
"rememberMe": true,
|
||||
}
|
||||
body, err := IntoReader(values)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
opts := rest.Opts{
|
||||
Method: "POST",
|
||||
Path: "/federate",
|
||||
Parameters: url.Values{"isRememberMeEnabled": {"true"}},
|
||||
ExtraHeaders: s.getSRPAuthHeaders(),
|
||||
RootURL: authEndpoint,
|
||||
Body: body,
|
||||
NoResponse: true,
|
||||
}
|
||||
|
||||
resp, err := s.srv.Call(ctx, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = resp.Body.Close()
|
||||
|
||||
if val := resp.Header.Get("X-Apple-Auth-Attributes"); val != "" {
|
||||
s.AuthAttributes = val
|
||||
}
|
||||
if val := resp.Header.Get("scnt"); val != "" {
|
||||
s.Scnt = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-ID-Session-Id"); val != "" {
|
||||
s.SessionID = val
|
||||
}
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
return fmt.Errorf("authFederate: unexpected status %s", resp.Status)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// authSRPInit sends the client's public value A to the server and retrieves
|
||||
// the salt, server public value B, iteration count, protocol, and challenge.
|
||||
func (s *Session) authSRPInit(ctx context.Context, aBase64, accountName string) (*srpInitResponse, error) {
|
||||
values := map[string]any{
|
||||
"a": aBase64,
|
||||
"accountName": accountName,
|
||||
"protocols": []string{"s2k", "s2k_fo"},
|
||||
}
|
||||
body, err := IntoReader(values)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opts := rest.Opts{
|
||||
Method: "POST",
|
||||
Path: "/signin/init",
|
||||
ExtraHeaders: s.getSRPAuthHeaders(),
|
||||
RootURL: authEndpoint,
|
||||
Body: body,
|
||||
}
|
||||
|
||||
var initResp srpInitResponse
|
||||
resp, err := s.srv.CallJSON(ctx, &opts, nil, &initResp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if val := resp.Header.Get("scnt"); val != "" {
|
||||
s.Scnt = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-ID-Session-Id"); val != "" {
|
||||
s.SessionID = val
|
||||
}
|
||||
|
||||
return &initResp, nil
|
||||
}
|
||||
|
||||
// authSRPComplete sends the SRP proofs M1 and M2 to complete authentication.
|
||||
// Returns nil on success (200 or 409/2FA needed).
|
||||
func (s *Session) authSRPComplete(ctx context.Context, accountName, m1Base64, m2Base64, c string) error {
|
||||
trustTokens := []string{}
|
||||
if s.TrustToken != "" {
|
||||
trustTokens = []string{s.TrustToken}
|
||||
}
|
||||
|
||||
values := map[string]any{
|
||||
"accountName": accountName,
|
||||
"m1": m1Base64,
|
||||
"m2": m2Base64,
|
||||
"c": c,
|
||||
"accountName": appleID,
|
||||
"password": password,
|
||||
"rememberMe": true,
|
||||
"trustTokens": trustTokens,
|
||||
}
|
||||
@@ -297,100 +82,21 @@ func (s *Session) authSRPComplete(ctx context.Context, accountName, m1Base64, m2
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
opts := rest.Opts{
|
||||
Method: "POST",
|
||||
Path: "/signin/complete",
|
||||
Parameters: url.Values{"isRememberMeEnabled": {"true"}},
|
||||
ExtraHeaders: s.getSRPAuthHeaders(),
|
||||
Path: "/signin",
|
||||
Parameters: url.Values{},
|
||||
ExtraHeaders: s.GetAuthHeaders(map[string]string{}),
|
||||
RootURL: authEndpoint,
|
||||
IgnoreStatus: true,
|
||||
IgnoreStatus: true, // need to handle 409 for hsa2
|
||||
NoResponse: true,
|
||||
Body: body,
|
||||
}
|
||||
opts.Parameters.Set("isRememberMeEnabled", "true")
|
||||
_, err = s.Request(ctx, opts, nil, nil)
|
||||
|
||||
resp, err := s.srv.Call(ctx, &opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_ = resp.Body.Close()
|
||||
return err
|
||||
|
||||
// Extract updated headers
|
||||
if val := resp.Header.Get("X-Apple-Auth-Attributes"); val != "" {
|
||||
s.AuthAttributes = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-Session-Token"); val != "" {
|
||||
s.SessionToken = val
|
||||
}
|
||||
if val := resp.Header.Get("scnt"); val != "" {
|
||||
s.Scnt = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-ID-Session-Id"); val != "" {
|
||||
s.SessionID = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-ID-Account-Country"); val != "" {
|
||||
s.AccountCountry = val
|
||||
}
|
||||
if val := resp.Header.Get("X-Apple-TwoSV-Trust-Token"); val != "" {
|
||||
s.TrustToken = val
|
||||
}
|
||||
|
||||
switch resp.StatusCode {
|
||||
case http.StatusOK:
|
||||
fs.Debugf("icloud", "SRP sign in successful")
|
||||
return nil
|
||||
case http.StatusConflict:
|
||||
// 409 = 2FA required, this is expected
|
||||
fs.Debugf("icloud", "SRP sign in requires 2FA")
|
||||
s.needs2FA = true
|
||||
return nil
|
||||
case http.StatusForbidden:
|
||||
return fmt.Errorf("sign in failed: incorrect username or password")
|
||||
default:
|
||||
return fmt.Errorf("sign in failed: %s", resp.Status)
|
||||
}
|
||||
}
|
||||
|
||||
// getAuthOrigin returns the origin URL for auth requests.
|
||||
// Supports both global (idmsa.apple.com) and China (idmsa.apple.com.cn) endpoints.
|
||||
func getAuthOrigin() string {
|
||||
return strings.TrimSuffix(authEndpoint, "/appleauth/auth")
|
||||
}
|
||||
|
||||
// getSRPAuthHeaders returns headers needed for SRP auth requests.
|
||||
func (s *Session) getSRPAuthHeaders() map[string]string {
|
||||
frameTag := "auth-" + s.FrameID
|
||||
authOrigin := getAuthOrigin()
|
||||
headers := map[string]string{
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"User-Agent": iCloudUserAgent,
|
||||
"Origin": authOrigin,
|
||||
"Referer": authOrigin + "/",
|
||||
"X-Apple-Widget-Key": s.ClientID,
|
||||
"X-Apple-OAuth-Client-Id": s.ClientID,
|
||||
"X-Apple-OAuth-Client-Type": "firstPartyAuth",
|
||||
"X-Apple-OAuth-Redirect-URI": "https://www.icloud.com",
|
||||
"X-Apple-OAuth-Require-Grant-Code": "true",
|
||||
"X-Apple-OAuth-Response-Mode": "web_message",
|
||||
"X-Apple-OAuth-Response-Type": "code",
|
||||
"X-Apple-OAuth-State": frameTag,
|
||||
"X-Apple-Frame-Id": frameTag,
|
||||
"X-Requested-With": "XMLHttpRequest",
|
||||
"X-Apple-Mandate-Security-Upgrade": "0",
|
||||
"X-Apple-I-Require-UE": "true",
|
||||
"X-Apple-I-FD-Client-Info": `{"U":"` + iCloudUserAgent + `","L":"en-US","Z":"GMT-05:00","V":"1.1","F":""}`,
|
||||
}
|
||||
if s.AuthAttributes != "" {
|
||||
headers["X-Apple-Auth-Attributes"] = s.AuthAttributes
|
||||
}
|
||||
if s.Scnt != "" {
|
||||
headers["scnt"] = s.Scnt
|
||||
}
|
||||
if s.SessionID != "" {
|
||||
headers["X-Apple-ID-Session-Id"] = s.SessionID
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
// AuthWithToken authenticates the session
|
||||
@@ -429,10 +135,14 @@ func (s *Session) Validate2FACode(ctx context.Context, code string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
headers := s.GetAuthHeaders(map[string]string{})
|
||||
headers["scnt"] = s.Scnt
|
||||
headers["X-Apple-ID-Session-Id"] = s.SessionID
|
||||
|
||||
opts := rest.Opts{
|
||||
Method: "POST",
|
||||
Path: "/verify/trusteddevice/securitycode",
|
||||
ExtraHeaders: s.GetAuthHeaders(map[string]string{}),
|
||||
ExtraHeaders: headers,
|
||||
RootURL: authEndpoint,
|
||||
Body: body,
|
||||
NoResponse: true,
|
||||
@@ -452,10 +162,14 @@ func (s *Session) Validate2FACode(ctx context.Context, code string) error {
|
||||
|
||||
// TrustSession trusts the session
|
||||
func (s *Session) TrustSession(ctx context.Context) error {
|
||||
headers := s.GetAuthHeaders(map[string]string{})
|
||||
headers["scnt"] = s.Scnt
|
||||
headers["X-Apple-ID-Session-Id"] = s.SessionID
|
||||
|
||||
opts := rest.Opts{
|
||||
Method: "GET",
|
||||
Path: "/2sv/trust",
|
||||
ExtraHeaders: s.GetAuthHeaders(map[string]string{}),
|
||||
ExtraHeaders: headers,
|
||||
RootURL: authEndpoint,
|
||||
NoResponse: true,
|
||||
ContentLength: common.Int64(0),
|
||||
@@ -487,9 +201,25 @@ func (s *Session) ValidateSession(ctx context.Context) error {
|
||||
}
|
||||
|
||||
// GetAuthHeaders returns the authentication headers for the session.
|
||||
// Used for 2FA validation and trust requests to idmsa.apple.com.
|
||||
//
|
||||
// It takes an `overwrite` map[string]string parameter which allows
|
||||
// overwriting the default headers. It returns a map[string]string.
|
||||
func (s *Session) GetAuthHeaders(overwrite map[string]string) map[string]string {
|
||||
headers := s.getSRPAuthHeaders()
|
||||
headers := map[string]string{
|
||||
"Accept": "application/json",
|
||||
"Content-Type": "application/json",
|
||||
"X-Apple-OAuth-Client-Id": s.ClientID,
|
||||
"X-Apple-OAuth-Client-Type": "firstPartyAuth",
|
||||
"X-Apple-OAuth-Redirect-URI": "https://www.icloud.com",
|
||||
"X-Apple-OAuth-Require-Grant-Code": "true",
|
||||
"X-Apple-OAuth-Response-Mode": "web_message",
|
||||
"X-Apple-OAuth-Response-Type": "code",
|
||||
"X-Apple-OAuth-State": s.ClientID,
|
||||
"X-Apple-Widget-Key": s.ClientID,
|
||||
"Origin": homeEndpoint,
|
||||
"Referer": fmt.Sprintf("%s/", homeEndpoint),
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0",
|
||||
}
|
||||
maps.Copy(headers, overwrite)
|
||||
return headers
|
||||
}
|
||||
@@ -518,7 +248,7 @@ func GetCommonHeaders(overwrite map[string]string) map[string]string {
|
||||
"Content-Type": "application/json",
|
||||
"Origin": baseEndpoint,
|
||||
"Referer": fmt.Sprintf("%s/", baseEndpoint),
|
||||
"User-Agent": iCloudUserAgent,
|
||||
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:103.0) Gecko/20100101 Firefox/103.0",
|
||||
}
|
||||
maps.Copy(headers, overwrite)
|
||||
return headers
|
||||
@@ -551,16 +281,9 @@ func GetCookiesForDomain(url *url.URL, cookies []*http.Cookie) ([]*http.Cookie,
|
||||
|
||||
// NewSession creates a new Session instance with default values.
|
||||
func NewSession() *Session {
|
||||
session := &Session{
|
||||
FrameID: strings.ToLower(uuid.New().String()),
|
||||
}
|
||||
httpClient := fshttp.NewClient(context.Background())
|
||||
if tr, ok := httpClient.Transport.(*fshttp.Transport); ok {
|
||||
tr.SetRequestFilter(func(req *http.Request) {
|
||||
req.Header.Set("User-Agent", iCloudUserAgent)
|
||||
})
|
||||
}
|
||||
session.srv = rest.NewClient(httpClient).SetRoot(baseEndpoint)
|
||||
session := &Session{}
|
||||
session.srv = rest.NewClient(fshttp.NewClient(context.Background())).SetRoot(baseEndpoint)
|
||||
//session.ClientID = "auth-" + uuid.New().String()
|
||||
return session
|
||||
}
|
||||
|
||||
|
||||
@@ -1,229 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"crypto/pbkdf2"
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"hash"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
// RFC 5054 2048-bit group parameters for SRP-6a (g=2, SHA-256).
|
||||
var (
|
||||
srpN = mustParseBigHex(
|
||||
"AC6BDB41324A9A9BF166DE5E1389582FAF72B6651987EE07FC3192943DB56050" +
|
||||
"A37329CBB4A099ED8193E0757767A13DD52312AB4B03310DCD7F48A9DA04FD50" +
|
||||
"E8083969EDB767B0CF6095179A163AB3661A05FBD5FAAAE82918A9962F0B93B8" +
|
||||
"55F97993EC975EEAA80D740ADBF4FF747359D041D5C33EA71D281E446B14773B" +
|
||||
"CA97B43A23FB801676BD207A436C6481F1D2B9078717461A5B9D32E688F87748" +
|
||||
"544523B524B0D57D5EA77A2775D2ECFA032CFBDBF52FB37861602790" +
|
||||
"04E57AE6AF874E7303CE53299CCC041C7BC308D82A5698F3A8D0C38271AE35F8" +
|
||||
"E9DBFBB694B5C803D89F7AE435DE236D525F54759B65E372FCD68EF20FA7111F" +
|
||||
"9E4AFF73")
|
||||
srpG = big.NewInt(2)
|
||||
srpNLenBytes = 2048 / 8
|
||||
srpHashFunc = sha256.New
|
||||
)
|
||||
|
||||
func mustParseBigHex(s string) *big.Int {
|
||||
b, ok := new(big.Int).SetString(s, 16)
|
||||
if !ok {
|
||||
panic("srp: bad hex constant for N")
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// srpClient implements the client side of SRP-6a for Apple's iCloud auth.
|
||||
type srpClient struct {
|
||||
a *big.Int // client secret
|
||||
A *big.Int // client public value
|
||||
k *big.Int // multiplier
|
||||
M1 []byte
|
||||
M2 []byte
|
||||
K []byte
|
||||
}
|
||||
|
||||
// newSRPClient generates a random 32-byte secret and computes the public value A.
|
||||
func newSRPClient() *srpClient {
|
||||
secret := make([]byte, 32)
|
||||
if _, err := rand.Read(secret); err != nil {
|
||||
panic(fmt.Sprintf("srp: rand.Read failed: %v", err))
|
||||
}
|
||||
|
||||
a := new(big.Int).SetBytes(secret)
|
||||
A := new(big.Int).Exp(srpG, a, srpN)
|
||||
k := getMultiplier()
|
||||
|
||||
return &srpClient{
|
||||
a: a,
|
||||
A: A,
|
||||
k: k,
|
||||
}
|
||||
}
|
||||
|
||||
// getABytes returns the padded public value A.
|
||||
func (c *srpClient) getABytes() []byte {
|
||||
return padToN(c.A)
|
||||
}
|
||||
|
||||
// processChallenge computes the session key and proof values from the server challenge.
|
||||
// username is the Apple ID, derivedKey is the output of derivePassword, salt and B come
|
||||
// from the server's init response (raw bytes, already base64-decoded).
|
||||
func (c *srpClient) processChallenge(username, derivedKey, salt, serverB []byte) {
|
||||
B := new(big.Int).SetBytes(serverB)
|
||||
|
||||
// Validate B
|
||||
if B.Cmp(big.NewInt(0)) <= 0 || B.Cmp(srpN) >= 0 {
|
||||
panic("srp: invalid server-supplied B, must be 1..N-1")
|
||||
}
|
||||
|
||||
x := calculateX(salt, derivedKey)
|
||||
u := calculateU(c.A, B)
|
||||
S := calculateS(c.k, x, c.a, B, u)
|
||||
c.K = calculateK(S)
|
||||
|
||||
aBytes := padToN(c.A)
|
||||
bBytes := padToN(B)
|
||||
c.M1 = calculateM1(username, salt, aBytes, bBytes, c.K)
|
||||
c.M2 = calculateM2(aBytes, c.M1, c.K)
|
||||
}
|
||||
|
||||
// derivePassword performs Apple's password key derivation.
|
||||
// For "s2k": PBKDF2(SHA256(password), salt, iterations, 32, SHA256)
|
||||
// For "s2k_fo": PBKDF2(hex(SHA256(password)), salt, iterations, 32, SHA256)
|
||||
func derivePassword(password string, salt []byte, iterations int, protocol string) ([]byte, error) {
|
||||
passHash := sha256.Sum256([]byte(password))
|
||||
|
||||
var passInput string
|
||||
switch protocol {
|
||||
case "s2k_fo":
|
||||
passInput = hex.EncodeToString(passHash[:])
|
||||
default: // "s2k"
|
||||
passInput = string(passHash[:])
|
||||
}
|
||||
return pbkdf2.Key(sha256.New, passInput, salt, iterations, 32)
|
||||
}
|
||||
|
||||
// padToN pads a big.Int to the SRP group size (256 bytes for 2048-bit).
|
||||
func padToN(n *big.Int) []byte {
|
||||
b := n.Bytes()
|
||||
if len(b) >= srpNLenBytes {
|
||||
return b
|
||||
}
|
||||
padded := make([]byte, srpNLenBytes)
|
||||
copy(padded[srpNLenBytes-len(b):], b)
|
||||
return padded
|
||||
}
|
||||
|
||||
func srpHash(data []byte) []byte {
|
||||
h := srpHashFunc()
|
||||
h.Write(data)
|
||||
return h.Sum(nil)
|
||||
}
|
||||
|
||||
func hashToInt(h hash.Hash) *big.Int {
|
||||
return new(big.Int).SetBytes(h.Sum(nil))
|
||||
}
|
||||
|
||||
// getMultiplier computes k = H(N | pad(g))
|
||||
func getMultiplier() *big.Int {
|
||||
h := srpHashFunc()
|
||||
nBytes := srpN.Bytes()
|
||||
gBytes := srpG.Bytes()
|
||||
// pad g to same length as N
|
||||
for len(gBytes) < len(nBytes) {
|
||||
gBytes = append([]byte{0}, gBytes...)
|
||||
}
|
||||
h.Write(nBytes)
|
||||
h.Write(gBytes)
|
||||
return hashToInt(h)
|
||||
}
|
||||
|
||||
// calculateX computes x = H(salt | H(":" | password))
|
||||
// Apple's variant: NoUserNameInX — username is omitted from the inner hash.
|
||||
// The "password" here is actually the derived key from derivePassword.
|
||||
func calculateX(salt, derivedKey []byte) *big.Int {
|
||||
h := srpHashFunc()
|
||||
// Apple omits username (NoUserNameInX), only writes ":" + derivedKey
|
||||
h.Write([]byte(":"))
|
||||
h.Write(derivedKey)
|
||||
digest := h.Sum(nil)
|
||||
|
||||
h2 := srpHashFunc()
|
||||
h2.Write(salt)
|
||||
h2.Write(digest)
|
||||
return new(big.Int).SetBytes(h2.Sum(nil))
|
||||
}
|
||||
|
||||
// calculateU computes u = H(pad(A) | pad(B))
|
||||
func calculateU(A, B *big.Int) *big.Int {
|
||||
h := srpHashFunc()
|
||||
h.Write(padToN(A))
|
||||
h.Write(padToN(B))
|
||||
return hashToInt(h)
|
||||
}
|
||||
|
||||
// calculateS computes the client-side shared secret:
|
||||
// S = (B - k * g^x) ^ (a + u*x) mod N
|
||||
func calculateS(k, x, a, B, u *big.Int) []byte {
|
||||
// g^x mod N
|
||||
gx := new(big.Int).Exp(srpG, x, srpN)
|
||||
|
||||
// k * g^x
|
||||
kgx := new(big.Int).Mul(k, gx)
|
||||
|
||||
// B - k*g^x
|
||||
diff := new(big.Int).Sub(B, kgx)
|
||||
|
||||
// u*x
|
||||
ux := new(big.Int).Mul(u, x)
|
||||
|
||||
// a + u*x
|
||||
exp := new(big.Int).Add(a, ux)
|
||||
|
||||
// (B - k*g^x) ^ (a + u*x) mod N
|
||||
S := new(big.Int).Exp(diff, exp, srpN)
|
||||
|
||||
// Ensure positive
|
||||
S.Mod(S, srpN)
|
||||
|
||||
return padToN(S)
|
||||
}
|
||||
|
||||
// calculateK computes K = H(S)
|
||||
func calculateK(S []byte) []byte {
|
||||
return srpHash(S)
|
||||
}
|
||||
|
||||
// calculateM1 computes the client proof (Apple/iCloud variant):
|
||||
// M1 = H(H(g) XOR H(N) | H(username) | salt | A | B | K)
|
||||
func calculateM1(username, salt, A, B, K []byte) []byte {
|
||||
hg := srpHash(padToN(srpG))
|
||||
hn := srpHash(srpN.Bytes())
|
||||
hi := srpHash(username)
|
||||
|
||||
hxor := make([]byte, len(hg))
|
||||
for i := range hg {
|
||||
hxor[i] = hg[i] ^ hn[i]
|
||||
}
|
||||
|
||||
h := srpHashFunc()
|
||||
h.Write(hxor)
|
||||
h.Write(hi)
|
||||
h.Write(salt)
|
||||
h.Write(A)
|
||||
h.Write(B)
|
||||
h.Write(K)
|
||||
return h.Sum(nil)
|
||||
}
|
||||
|
||||
// calculateM2 computes the server proof: M2 = H(A | M1 | K)
|
||||
func calculateM2(A, M1, K []byte) []byte {
|
||||
h := srpHashFunc()
|
||||
h.Write(A)
|
||||
h.Write(M1)
|
||||
h.Write(K)
|
||||
return h.Sum(nil)
|
||||
}
|
||||
@@ -1,379 +0,0 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestPadToN(t *testing.T) {
|
||||
t.Run("pads small value to 256 bytes", func(t *testing.T) {
|
||||
result := padToN(big.NewInt(1))
|
||||
assert.Equal(t, srpNLenBytes, len(result))
|
||||
assert.Equal(t, byte(0), result[0])
|
||||
assert.Equal(t, byte(1), result[srpNLenBytes-1])
|
||||
})
|
||||
|
||||
t.Run("pads zero to 256 bytes", func(t *testing.T) {
|
||||
result := padToN(big.NewInt(0))
|
||||
assert.Equal(t, srpNLenBytes, len(result))
|
||||
for _, b := range result {
|
||||
assert.Equal(t, byte(0), b)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("preserves value that fills N", func(t *testing.T) {
|
||||
// Use N itself — already 256 bytes
|
||||
result := padToN(srpN)
|
||||
assert.Equal(t, srpNLenBytes, len(result))
|
||||
assert.Equal(t, srpN.Bytes(), result)
|
||||
})
|
||||
|
||||
t.Run("round-trips through big.Int", func(t *testing.T) {
|
||||
original := big.NewInt(123456789)
|
||||
padded := padToN(original)
|
||||
recovered := new(big.Int).SetBytes(padded)
|
||||
assert.Equal(t, 0, original.Cmp(recovered))
|
||||
})
|
||||
}
|
||||
|
||||
func TestGetMultiplier(t *testing.T) {
|
||||
k := getMultiplier()
|
||||
|
||||
// k must be non-zero and less than N
|
||||
assert.True(t, k.Sign() > 0, "multiplier must be positive")
|
||||
assert.True(t, k.Cmp(srpN) < 0, "multiplier must be less than N")
|
||||
|
||||
// k is deterministic
|
||||
k2 := getMultiplier()
|
||||
assert.Equal(t, 0, k.Cmp(k2), "multiplier must be deterministic")
|
||||
|
||||
// k = H(N | pad(g)) — verify by manual computation
|
||||
h := srpHashFunc()
|
||||
nBytes := srpN.Bytes()
|
||||
gBytes := srpG.Bytes()
|
||||
for len(gBytes) < len(nBytes) {
|
||||
gBytes = append([]byte{0}, gBytes...)
|
||||
}
|
||||
h.Write(nBytes)
|
||||
h.Write(gBytes)
|
||||
expected := new(big.Int).SetBytes(h.Sum(nil))
|
||||
assert.Equal(t, 0, expected.Cmp(k), "multiplier must equal H(N|pad(g))")
|
||||
}
|
||||
|
||||
func TestDerivePassword(t *testing.T) {
|
||||
salt := []byte("test_salt_value!")
|
||||
password := "test_password"
|
||||
|
||||
t.Run("s2k produces 32-byte key", func(t *testing.T) {
|
||||
key, err := derivePassword(password, salt, 1000, "s2k")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 32, len(key))
|
||||
})
|
||||
|
||||
t.Run("s2k_fo produces 32-byte key", func(t *testing.T) {
|
||||
key, err := derivePassword(password, salt, 1000, "s2k_fo")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 32, len(key))
|
||||
})
|
||||
|
||||
t.Run("s2k and s2k_fo produce different keys", func(t *testing.T) {
|
||||
key1, err := derivePassword(password, salt, 1000, "s2k")
|
||||
require.NoError(t, err)
|
||||
key2, err := derivePassword(password, salt, 1000, "s2k_fo")
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, key1, key2, "s2k and s2k_fo must produce different keys")
|
||||
})
|
||||
|
||||
t.Run("deterministic output", func(t *testing.T) {
|
||||
key1, err := derivePassword(password, salt, 1000, "s2k")
|
||||
require.NoError(t, err)
|
||||
key2, err := derivePassword(password, salt, 1000, "s2k")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, key1, key2)
|
||||
})
|
||||
|
||||
t.Run("different passwords produce different keys", func(t *testing.T) {
|
||||
key1, err := derivePassword("password1", salt, 1000, "s2k")
|
||||
require.NoError(t, err)
|
||||
key2, err := derivePassword("password2", salt, 1000, "s2k")
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, key1, key2)
|
||||
})
|
||||
|
||||
t.Run("s2k uses raw SHA256 bytes", func(t *testing.T) {
|
||||
// Verify that s2k uses SHA256(password) as the PBKDF2 input.
|
||||
// Two passwords with the same SHA256 hash would produce the same key,
|
||||
// while two passwords with different SHA256 hashes must produce different keys.
|
||||
key1, err := derivePassword("hello", salt, 10, "s2k")
|
||||
require.NoError(t, err)
|
||||
key2, err := derivePassword("world", salt, 10, "s2k")
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, key1, key2)
|
||||
})
|
||||
|
||||
t.Run("s2k_fo uses hex-encoded SHA256", func(t *testing.T) {
|
||||
// For s2k_fo, the PBKDF2 input is hex(SHA256(password)), which is
|
||||
// a 64-character ASCII string, not raw 32-byte hash.
|
||||
key, err := derivePassword("hello", salt, 10, "s2k_fo")
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 32, len(key))
|
||||
})
|
||||
}
|
||||
|
||||
func TestCalculateX(t *testing.T) {
|
||||
salt := []byte("some_salt")
|
||||
derivedKey := []byte("some_derived_key_value_32_bytes!")
|
||||
|
||||
x := calculateX(salt, derivedKey)
|
||||
|
||||
// x must be positive and less than the hash output space
|
||||
assert.True(t, x.Sign() > 0, "x must be positive")
|
||||
|
||||
// x is deterministic
|
||||
x2 := calculateX(salt, derivedKey)
|
||||
assert.Equal(t, 0, x.Cmp(x2), "x must be deterministic")
|
||||
|
||||
// Verify manually: x = H(salt | H(":" | derivedKey))
|
||||
h1 := srpHashFunc()
|
||||
h1.Write([]byte(":"))
|
||||
h1.Write(derivedKey)
|
||||
inner := h1.Sum(nil)
|
||||
|
||||
h2 := srpHashFunc()
|
||||
h2.Write(salt)
|
||||
h2.Write(inner)
|
||||
expected := new(big.Int).SetBytes(h2.Sum(nil))
|
||||
assert.Equal(t, 0, expected.Cmp(x), "x must equal H(salt | H(\":\" | derivedKey))")
|
||||
}
|
||||
|
||||
func TestCalculateU(t *testing.T) {
|
||||
A := big.NewInt(12345)
|
||||
B := big.NewInt(67890)
|
||||
|
||||
u := calculateU(A, B)
|
||||
assert.True(t, u.Sign() > 0, "u must be positive")
|
||||
|
||||
// u is deterministic
|
||||
u2 := calculateU(A, B)
|
||||
assert.Equal(t, 0, u.Cmp(u2))
|
||||
|
||||
// u changes when inputs change
|
||||
u3 := calculateU(A, big.NewInt(99999))
|
||||
assert.NotEqual(t, 0, u.Cmp(u3), "u must change when B changes")
|
||||
|
||||
// Verify: u = H(pad(A) | pad(B))
|
||||
h := srpHashFunc()
|
||||
h.Write(padToN(A))
|
||||
h.Write(padToN(B))
|
||||
expected := new(big.Int).SetBytes(h.Sum(nil))
|
||||
assert.Equal(t, 0, expected.Cmp(u))
|
||||
}
|
||||
|
||||
func TestCalculateK(t *testing.T) {
|
||||
S := []byte("some_shared_secret_value_32bytes")
|
||||
|
||||
K := calculateK(S)
|
||||
|
||||
// K is a SHA-256 hash, so 32 bytes
|
||||
assert.Equal(t, sha256.Size, len(K))
|
||||
|
||||
// K is deterministic
|
||||
K2 := calculateK(S)
|
||||
assert.Equal(t, K, K2)
|
||||
|
||||
// Verify: K = H(S)
|
||||
expected := srpHash(S)
|
||||
assert.Equal(t, expected, K)
|
||||
}
|
||||
|
||||
func TestCalculateM1(t *testing.T) {
|
||||
username := []byte("test@example.com")
|
||||
salt := []byte("test_salt")
|
||||
A := make([]byte, srpNLenBytes)
|
||||
B := make([]byte, srpNLenBytes)
|
||||
K := make([]byte, 32)
|
||||
|
||||
// Fill with non-zero values
|
||||
A[srpNLenBytes-1] = 0x42
|
||||
B[srpNLenBytes-1] = 0x43
|
||||
K[0] = 0x44
|
||||
|
||||
m1 := calculateM1(username, salt, A, B, K)
|
||||
|
||||
// M1 is a SHA-256 hash
|
||||
assert.Equal(t, sha256.Size, len(m1))
|
||||
|
||||
// M1 is deterministic
|
||||
m1b := calculateM1(username, salt, A, B, K)
|
||||
assert.Equal(t, m1, m1b)
|
||||
|
||||
// M1 changes when username changes
|
||||
m1c := calculateM1([]byte("other@example.com"), salt, A, B, K)
|
||||
assert.NotEqual(t, m1, m1c)
|
||||
|
||||
// Verify: M1 = H(H(g) XOR H(N) | H(username) | salt | A | B | K)
|
||||
hg := srpHash(padToN(srpG))
|
||||
hn := srpHash(srpN.Bytes())
|
||||
hi := srpHash(username)
|
||||
hxor := make([]byte, len(hg))
|
||||
for i := range hg {
|
||||
hxor[i] = hg[i] ^ hn[i]
|
||||
}
|
||||
h := srpHashFunc()
|
||||
h.Write(hxor)
|
||||
h.Write(hi)
|
||||
h.Write(salt)
|
||||
h.Write(A)
|
||||
h.Write(B)
|
||||
h.Write(K)
|
||||
expected := h.Sum(nil)
|
||||
assert.Equal(t, expected, m1)
|
||||
}
|
||||
|
||||
func TestCalculateM2(t *testing.T) {
|
||||
A := make([]byte, srpNLenBytes)
|
||||
M1 := make([]byte, 32)
|
||||
K := make([]byte, 32)
|
||||
|
||||
A[srpNLenBytes-1] = 0x01
|
||||
M1[0] = 0x02
|
||||
K[0] = 0x03
|
||||
|
||||
m2 := calculateM2(A, M1, K)
|
||||
assert.Equal(t, sha256.Size, len(m2))
|
||||
|
||||
// Verify: M2 = H(A | M1 | K)
|
||||
h := srpHashFunc()
|
||||
h.Write(A)
|
||||
h.Write(M1)
|
||||
h.Write(K)
|
||||
assert.Equal(t, h.Sum(nil), m2)
|
||||
}
|
||||
|
||||
func TestNewSRPClient(t *testing.T) {
|
||||
client := newSRPClient()
|
||||
|
||||
// A must be non-zero and in range [1, N-1]
|
||||
assert.True(t, client.A.Sign() > 0, "A must be positive")
|
||||
assert.True(t, client.A.Cmp(srpN) < 0, "A must be less than N")
|
||||
|
||||
// A = g^a mod N
|
||||
expectedA := new(big.Int).Exp(srpG, client.a, srpN)
|
||||
assert.Equal(t, 0, expectedA.Cmp(client.A), "A must equal g^a mod N")
|
||||
|
||||
// getABytes returns padded A
|
||||
aBytes := client.getABytes()
|
||||
assert.Equal(t, srpNLenBytes, len(aBytes))
|
||||
recoveredA := new(big.Int).SetBytes(aBytes)
|
||||
assert.Equal(t, 0, client.A.Cmp(recoveredA))
|
||||
|
||||
// Two clients should have different secrets (probabilistic, but 2^256 collision chance)
|
||||
client2 := newSRPClient()
|
||||
assert.NotEqual(t, 0, client.a.Cmp(client2.a), "two clients must have different secrets")
|
||||
}
|
||||
|
||||
func TestProcessChallenge(t *testing.T) {
|
||||
// Use a fixed secret for deterministic testing
|
||||
fixedSecret := make([]byte, 32)
|
||||
fixedSecret[31] = 0x42 // small non-zero value
|
||||
|
||||
a := new(big.Int).SetBytes(fixedSecret)
|
||||
A := new(big.Int).Exp(srpG, a, srpN)
|
||||
k := getMultiplier()
|
||||
|
||||
client := &srpClient{
|
||||
a: a,
|
||||
A: A,
|
||||
k: k,
|
||||
}
|
||||
|
||||
username := []byte("testuser@apple.com")
|
||||
derivedKey := make([]byte, 32)
|
||||
for i := range derivedKey {
|
||||
derivedKey[i] = byte(i)
|
||||
}
|
||||
salt := []byte("fixed_salt_for_test!")
|
||||
|
||||
// Compute a valid B: B = (k*v + g^b) mod N where v = g^x mod N
|
||||
x := calculateX(salt, derivedKey)
|
||||
v := new(big.Int).Exp(srpG, x, srpN)
|
||||
|
||||
bSecret := make([]byte, 32)
|
||||
bSecret[31] = 0x99
|
||||
b := new(big.Int).SetBytes(bSecret)
|
||||
|
||||
// B = (k*v + g^b) mod N
|
||||
kv := new(big.Int).Mul(k, v)
|
||||
gb := new(big.Int).Exp(srpG, b, srpN)
|
||||
B := new(big.Int).Add(kv, gb)
|
||||
B.Mod(B, srpN)
|
||||
|
||||
serverB := padToN(B)
|
||||
|
||||
client.processChallenge(username, derivedKey, salt, serverB)
|
||||
|
||||
// M1, M2, K must be populated
|
||||
assert.NotNil(t, client.M1)
|
||||
assert.NotNil(t, client.M2)
|
||||
assert.NotNil(t, client.K)
|
||||
assert.Equal(t, sha256.Size, len(client.M1))
|
||||
assert.Equal(t, sha256.Size, len(client.M2))
|
||||
assert.Equal(t, sha256.Size, len(client.K))
|
||||
|
||||
// M1 and M2 must be different
|
||||
assert.NotEqual(t, client.M1, client.M2)
|
||||
|
||||
// Results must be deterministic — run again with same inputs
|
||||
client2 := &srpClient{
|
||||
a: new(big.Int).Set(a),
|
||||
A: new(big.Int).Set(A),
|
||||
k: new(big.Int).Set(k),
|
||||
}
|
||||
client2.processChallenge(username, derivedKey, salt, serverB)
|
||||
|
||||
assert.Equal(t, client.M1, client2.M1, "M1 must be deterministic")
|
||||
assert.Equal(t, client.M2, client2.M2, "M2 must be deterministic")
|
||||
assert.Equal(t, client.K, client2.K, "K must be deterministic")
|
||||
|
||||
// Verify the server could also compute S and get the same K.
|
||||
// Server computes: S_server = (A * v^u)^b mod N
|
||||
u := calculateU(A, B)
|
||||
vu := new(big.Int).Exp(v, u, srpN)
|
||||
avu := new(big.Int).Mul(A, vu)
|
||||
avu.Mod(avu, srpN)
|
||||
sServer := new(big.Int).Exp(avu, b, srpN)
|
||||
sServer.Mod(sServer, srpN)
|
||||
kServer := calculateK(padToN(sServer))
|
||||
assert.Equal(t, client.K, kServer, "client and server must derive the same session key")
|
||||
}
|
||||
|
||||
func TestSRPGroupParameters(t *testing.T) {
|
||||
// Verify the 2048-bit prime starts with known hex prefix
|
||||
nHex := hex.EncodeToString(srpN.Bytes())
|
||||
assert.True(t, len(nHex) > 0)
|
||||
assert.Equal(t, "ac6bdb41", nHex[:8], "N must start with known prefix")
|
||||
|
||||
// g must be 2
|
||||
assert.Equal(t, int64(2), srpG.Int64())
|
||||
|
||||
// N byte length must match expected
|
||||
assert.Equal(t, 256, srpNLenBytes)
|
||||
assert.Equal(t, 256, len(srpN.Bytes()))
|
||||
}
|
||||
|
||||
func TestSRPHash(t *testing.T) {
|
||||
data := []byte("hello world")
|
||||
hash := srpHash(data)
|
||||
|
||||
// Must be SHA-256 output
|
||||
assert.Equal(t, sha256.Size, len(hash))
|
||||
|
||||
// Must equal standard sha256
|
||||
expected := sha256.Sum256(data)
|
||||
assert.Equal(t, expected[:], hash)
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//go:build !linux
|
||||
|
||||
package local
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
func newFadviseReadCloser(o *Object, f *os.File, offset, limit int64) io.ReadCloser {
|
||||
return f
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
//go:build linux
|
||||
|
||||
package local
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
// fadvise provides means to automate freeing pages in kernel page cache for
|
||||
// a given file descriptor as the file is sequentially processed (read or
|
||||
// written).
|
||||
//
|
||||
// When copying a file to a remote backend all the file content is read by
|
||||
// kernel and put to page cache to make future reads faster.
|
||||
// This causes memory pressure visible in both memory usage and CPU consumption
|
||||
// and can even cause OOM errors in applications consuming large amounts memory.
|
||||
//
|
||||
// In case of an upload to a remote backend, there is no benefits from caching.
|
||||
//
|
||||
// fadvise would orchestrate calling POSIX_FADV_DONTNEED
|
||||
//
|
||||
// POSIX_FADV_DONTNEED attempts to free cached pages associated
|
||||
// with the specified region. This is useful, for example, while
|
||||
// streaming large files. A program may periodically request the
|
||||
// kernel to free cached data that has already been used, so that
|
||||
// more useful cached pages are not discarded instead.
|
||||
//
|
||||
// Requests to discard partial pages are ignored. It is
|
||||
// preferable to preserve needed data than discard unneeded data.
|
||||
// If the application requires that data be considered for
|
||||
// discarding, then offset and len must be page-aligned.
|
||||
//
|
||||
// The implementation may attempt to write back dirty pages in
|
||||
// the specified region, but this is not guaranteed. Any
|
||||
// unwritten dirty pages will not be freed. If the application
|
||||
// wishes to ensure that dirty pages will be released, it should
|
||||
// call fsync(2) or fdatasync(2) first.
|
||||
type fadvise struct {
|
||||
o *Object
|
||||
fd int
|
||||
lastPos int64
|
||||
curPos int64
|
||||
windowSize int64
|
||||
|
||||
freePagesCh chan offsetLength
|
||||
doneCh chan struct{}
|
||||
}
|
||||
|
||||
type offsetLength struct {
|
||||
offset int64
|
||||
length int64
|
||||
}
|
||||
|
||||
const (
|
||||
defaultAllowPages = 32
|
||||
defaultWorkerQueueSize = 64
|
||||
)
|
||||
|
||||
func newFadvise(o *Object, fd int, offset int64) *fadvise {
|
||||
f := &fadvise{
|
||||
o: o,
|
||||
fd: fd,
|
||||
lastPos: offset,
|
||||
curPos: offset,
|
||||
windowSize: int64(os.Getpagesize()) * defaultAllowPages,
|
||||
|
||||
freePagesCh: make(chan offsetLength, defaultWorkerQueueSize),
|
||||
doneCh: make(chan struct{}),
|
||||
}
|
||||
go f.worker()
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
// sequential configures readahead strategy in Linux kernel.
|
||||
//
|
||||
// Under Linux, POSIX_FADV_NORMAL sets the readahead window to the
|
||||
// default size for the backing device; POSIX_FADV_SEQUENTIAL doubles
|
||||
// this size, and POSIX_FADV_RANDOM disables file readahead entirely.
|
||||
func (f *fadvise) sequential(limit int64) bool {
|
||||
l := int64(0)
|
||||
if limit > 0 {
|
||||
l = limit
|
||||
}
|
||||
if err := unix.Fadvise(f.fd, f.curPos, l, unix.FADV_SEQUENTIAL); err != nil {
|
||||
fs.Debugf(f.o, "fadvise sequential failed on file descriptor %d: %s", f.fd, err)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func (f *fadvise) next(n int) {
|
||||
f.curPos += int64(n)
|
||||
f.freePagesIfNeeded()
|
||||
}
|
||||
|
||||
func (f *fadvise) freePagesIfNeeded() {
|
||||
if f.curPos >= f.lastPos+f.windowSize {
|
||||
f.freePages()
|
||||
}
|
||||
}
|
||||
|
||||
func (f *fadvise) freePages() {
|
||||
f.freePagesCh <- offsetLength{f.lastPos, f.curPos - f.lastPos}
|
||||
f.lastPos = f.curPos
|
||||
}
|
||||
|
||||
func (f *fadvise) worker() {
|
||||
for p := range f.freePagesCh {
|
||||
if err := unix.Fadvise(f.fd, p.offset, p.length, unix.FADV_DONTNEED); err != nil {
|
||||
fs.Debugf(f.o, "fadvise dontneed failed on file descriptor %d: %s", f.fd, err)
|
||||
}
|
||||
}
|
||||
|
||||
close(f.doneCh)
|
||||
}
|
||||
|
||||
func (f *fadvise) wait() {
|
||||
close(f.freePagesCh)
|
||||
<-f.doneCh
|
||||
}
|
||||
|
||||
type fadviseReadCloser struct {
|
||||
*fadvise
|
||||
inner io.ReadCloser
|
||||
}
|
||||
|
||||
// newFadviseReadCloser wraps os.File so that reading from that file would
|
||||
// remove already consumed pages from kernel page cache.
|
||||
// In addition to that it instructs kernel to double the readahead window to
|
||||
// make sequential reads faster.
|
||||
// See also fadvise.
|
||||
func newFadviseReadCloser(o *Object, f *os.File, offset, limit int64) io.ReadCloser {
|
||||
r := fadviseReadCloser{
|
||||
fadvise: newFadvise(o, int(f.Fd()), offset),
|
||||
inner: f,
|
||||
}
|
||||
|
||||
// If syscall failed it's likely that the subsequent syscalls to that
|
||||
// file descriptor would also fail. In that case return the provided os.File
|
||||
// pointer.
|
||||
if !r.sequential(limit) {
|
||||
r.wait()
|
||||
return f
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
func (f fadviseReadCloser) Read(p []byte) (n int, err error) {
|
||||
n, err = f.inner.Read(p)
|
||||
f.next(n)
|
||||
return
|
||||
}
|
||||
|
||||
func (f fadviseReadCloser) Close() error {
|
||||
f.freePages()
|
||||
f.wait()
|
||||
return f.inner.Close()
|
||||
}
|
||||
@@ -1168,7 +1168,7 @@ func (o *Object) Hash(ctx context.Context, r hash.Type) (string, error) {
|
||||
var fd *os.File
|
||||
fd, err = file.Open(o.path)
|
||||
if fd != nil {
|
||||
in = fd
|
||||
in = newFadviseReadCloser(o, fd, 0, 0)
|
||||
}
|
||||
} else {
|
||||
in, err = o.openTranslatedLink(0, -1)
|
||||
@@ -1374,7 +1374,7 @@ func (o *Object) Open(ctx context.Context, options ...fs.OpenOption) (in io.Read
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
wrappedFd := readers.NewLimitedReadCloser(fd, limit)
|
||||
wrappedFd := readers.NewLimitedReadCloser(newFadviseReadCloser(o, fd, offset, limit), limit)
|
||||
if offset != 0 {
|
||||
// seek the object
|
||||
_, err = fd.Seek(offset, io.SeekStart)
|
||||
|
||||
@@ -16,12 +16,11 @@ type Authenticator interface {
|
||||
}
|
||||
|
||||
// IbmIamSigner is a structure for signing requests using IBM IAM.
|
||||
// Requires APIKey and Resource InstanceID
|
||||
// Requeres APIKey and Resource InstanceID
|
||||
type IbmIamSigner struct {
|
||||
APIKey string
|
||||
InstanceID string
|
||||
IAMEndpoint string
|
||||
Auth Authenticator
|
||||
APIKey string
|
||||
InstanceID string
|
||||
Auth Authenticator
|
||||
}
|
||||
|
||||
// SignHTTP signs requests using IBM IAM token.
|
||||
@@ -30,7 +29,7 @@ func (signer *IbmIamSigner) SignHTTP(ctx context.Context, credentials aws.Creden
|
||||
if signer.Auth != nil {
|
||||
authenticator = signer.Auth
|
||||
} else {
|
||||
authenticator = &core.IamAuthenticator{ApiKey: signer.APIKey, URL: signer.IAMEndpoint}
|
||||
authenticator = &core.IamAuthenticator{ApiKey: signer.APIKey}
|
||||
}
|
||||
token, err := authenticator.GetToken()
|
||||
if err != nil {
|
||||
|
||||
@@ -23,16 +23,14 @@ func TestSignHTTP(t *testing.T) {
|
||||
apiKey := "mock-api-key"
|
||||
instanceID := "mock-instance-id"
|
||||
token := "mock-iam-token"
|
||||
iamEndpoint := "https://iamendpoint.com"
|
||||
mockAuth := &MockAuthenticator{
|
||||
Token: token,
|
||||
Error: nil,
|
||||
}
|
||||
signer := &IbmIamSigner{
|
||||
APIKey: apiKey,
|
||||
InstanceID: instanceID,
|
||||
IAMEndpoint: iamEndpoint,
|
||||
Auth: mockAuth,
|
||||
APIKey: apiKey,
|
||||
InstanceID: instanceID,
|
||||
Auth: mockAuth,
|
||||
}
|
||||
req, err := http.NewRequest("GET", "https://example.com", nil)
|
||||
if err != nil {
|
||||
|
||||
@@ -4,7 +4,6 @@ region:
|
||||
eu-west-1: Europe West
|
||||
endpoint:
|
||||
s3.cubbit.eu: Cubbit DS3 Object Storage endpoint
|
||||
s3.{tenant_name}.cubbit.eu: Multi-tenant endpoint - replace {tenant_name} with your actual tenant name. Do not select this directly
|
||||
acl: {}
|
||||
bucket_acl: true
|
||||
quirks:
|
||||
|
||||
@@ -18,7 +18,3 @@ quirks:
|
||||
# See: https://issuetracker.google.com/issues/323465186
|
||||
# So make cutoff very large which it does seem to support
|
||||
copy_cutoff: 9223372036854775807
|
||||
# GCS S3 API doesn't fully support Object Lock:
|
||||
# - Uses x-goog-bypass-governance-retention instead of x-amz-bypass-governance-retention
|
||||
# - PutObjectLegalHold / GetObjectLegalHold not implemented
|
||||
object_lock_supported: false
|
||||
@@ -117,7 +117,6 @@ acl:
|
||||
This acl is available on IBM Cloud (Infra) and On-Premise IBM COS.
|
||||
ibm_api_key: true
|
||||
ibm_resource_instance_id: true
|
||||
ibm_iam_endpoint: true
|
||||
bucket_acl: true
|
||||
quirks:
|
||||
list_version: 1
|
||||
|
||||
@@ -32,15 +32,5 @@ endpoint:
|
||||
s3.us-east-va.io.cloud.ovh.us: OVHcloud Vint Hill, Virginia, USA
|
||||
s3.us-west-or.io.cloud.ovh.us: OVHcloud Hillsboro, Oregon, USA
|
||||
s3.rbx-archive.io.cloud.ovh.net: OVHcloud Roubaix, France (Cold Archive)
|
||||
storage_class:
|
||||
'': Default
|
||||
EXPRESS_ONEZONE: High Performance storage class
|
||||
STANDARD: Standard storage class
|
||||
STANDARD_IA: Standard Infrequent Access storage class
|
||||
ONEZONE_IA: Standard Infrequent Access storage class
|
||||
GLACIER: Active Archive storage class
|
||||
GLACIER_IR: Active Archive storage class
|
||||
DEEP_ARCHIVE: Cold Archive storage class
|
||||
INTELLIGENT_TIERING: Standard storage class
|
||||
acl: {}
|
||||
bucket_acl: true
|
||||
@@ -1,44 +0,0 @@
|
||||
name: US3
|
||||
description: US3 Object Storage
|
||||
endpoint:
|
||||
s3-cn-bj.ufileos.com: North China (Beijing 2)
|
||||
s3-cn-wlcb.ufileos.com: North China (Ulanqab)
|
||||
s3-cn-sh2.ufileos.com: Shanghai
|
||||
s3-cn-gd.ufileos.com: South China (Guangzhou)
|
||||
s3-hk.ufileos.com: Hongkong
|
||||
s3-us-ca.ufileos.com: United States (Los Angeles)
|
||||
s3-sg.ufileos.com: Singapore
|
||||
s3-idn-jakarta.ufileos.com: Indonesia (Jakarta)
|
||||
s3-tw-tp.ufileos.com: Taiwan (Taipei)
|
||||
s3-afr-nigeria.ufileos.com: Nigeria (Lagos)
|
||||
s3-bra-saopaulo.ufileos.com: Brazil (São Paulo)
|
||||
s3-uae-dubai.ufileos.com: United Arab Emirates (Dubai)
|
||||
s3-ge-fra.ufileos.com: Germany (Frankfurt)
|
||||
s3-vn-sng.ufileos.com: Vietnam (Ho Chi Minh City)
|
||||
s3-us-ws.ufileos.com: United States (Washington)
|
||||
s3-ind-mumbai.ufileos.com: India (Mumbai)
|
||||
s3-kr-seoul.ufileos.com: Seoul (South Korea)
|
||||
s3-jpn-tky.ufileos.com: Japan (Tokyo)
|
||||
s3-th-bkk.ufileos.com: Bangkok (Thailand)
|
||||
s3-uk-london.ufileos.com: United Kingdom (London)
|
||||
s3-rus-mosc.ufileos.com: Russia (Moscow)
|
||||
s3-cn-guiyang1.ufileos.com: Guiyang 1
|
||||
s3-pk-khi.ufileos.com: Pakistan
|
||||
acl:
|
||||
private: |-
|
||||
Owner gets FULL_CONTROL.
|
||||
No one else has access rights (default).
|
||||
public-read: |-
|
||||
Owner gets FULL_CONTROL.
|
||||
The AllUsers group gets READ access.
|
||||
storage_class:
|
||||
'': Default
|
||||
STANDARD: Standard storage class
|
||||
ARCHIVE: Archive storage mode
|
||||
STANDARD_IA: Infrequent access storage mode
|
||||
bucket_acl: true
|
||||
quirks:
|
||||
list_version: 1
|
||||
use_multipart_etag: false
|
||||
use_already_exists: false
|
||||
list_url_encode: true
|
||||
@@ -33,7 +33,6 @@ type Quirks struct {
|
||||
UseXID *bool `yaml:"use_x_id,omitempty"`
|
||||
SignAcceptEncoding *bool `yaml:"sign_accept_encoding,omitempty"`
|
||||
EtagIsNotMD5 *bool `yaml:"etag_is_not_md5,omitempty"`
|
||||
ObjectLockSupported *bool `yaml:"object_lock_supported,omitempty"`
|
||||
CopyCutoff *int64 `yaml:"copy_cutoff,omitempty"`
|
||||
MaxUploadParts *int `yaml:"max_upload_parts,omitempty"`
|
||||
MinChunkSize *int64 `yaml:"min_chunk_size,omitempty"`
|
||||
@@ -53,7 +52,6 @@ type Provider struct {
|
||||
// other
|
||||
IBMApiKey bool `yaml:"ibm_api_key,omitempty"`
|
||||
IBMResourceInstanceID bool `yaml:"ibm_resource_instance_id,omitempty"`
|
||||
IBMIAMEndpoint bool `yaml:"ibm_iam_endpoint,omitempty"`
|
||||
|
||||
// advanced
|
||||
BucketACL bool `yaml:"bucket_acl,omitempty"`
|
||||
@@ -226,8 +224,6 @@ func constructProviders(options fs.Options, providerMap map[string]*Provider) st
|
||||
addBool(opt, p, p.IBMApiKey)
|
||||
case "ibm_resource_instance_id":
|
||||
addBool(opt, p, p.IBMResourceInstanceID)
|
||||
case "ibm_iam_endpoint":
|
||||
addBool(opt, p, p.IBMIAMEndpoint)
|
||||
case "leave_parts_on_error":
|
||||
addBool(opt, p, p.LeavePartsOnError)
|
||||
case "sts_endpoint":
|
||||
|
||||
+1
-49
@@ -4,7 +4,6 @@ package s3
|
||||
//go:generate go run gen_setfrom.go -o setfrom.go
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"crypto/md5"
|
||||
"crypto/tls"
|
||||
@@ -830,10 +829,6 @@ use |-vv| to see the debug level logs.
|
||||
}, {
|
||||
Name: "ibm_resource_instance_id",
|
||||
Help: "IBM service instance id",
|
||||
}, {
|
||||
Name: "ibm_iam_endpoint",
|
||||
Help: "IBM IAM Endpoint to use for authentication.\n\nLeave blank to use the default public endpoint.",
|
||||
Advanced: true,
|
||||
}, {
|
||||
Name: "object_lock_mode",
|
||||
Help: `Object Lock mode to apply when uploading or copying objects.
|
||||
@@ -935,18 +930,6 @@ PutObjectRetention and PutObjectLegalHold API calls after the upload completes.
|
||||
This adds extra API calls per object, so only enable if your provider requires it.`,
|
||||
Default: false,
|
||||
Advanced: true,
|
||||
}, {
|
||||
Name: "object_lock_supported",
|
||||
Help: `Whether the provider supports S3 Object Lock.
|
||||
|
||||
This should be true, false or left unset to use the default for the provider.
|
||||
|
||||
Set to false for providers that don't fully support the S3 Object Lock API
|
||||
(e.g. GCS which uses non-standard headers for bypass governance retention
|
||||
and doesn't implement Legal Hold via the S3 API).
|
||||
`,
|
||||
Default: fs.Tristate{},
|
||||
Advanced: true,
|
||||
},
|
||||
}}))
|
||||
}
|
||||
@@ -1124,7 +1107,6 @@ type Options struct {
|
||||
DirectoryBucket bool `config:"directory_bucket"`
|
||||
IBMAPIKey string `config:"ibm_api_key"`
|
||||
IBMInstanceID string `config:"ibm_resource_instance_id"`
|
||||
IBMIAMEndpoint string `config:"ibm_iam_endpoint"`
|
||||
UseXID fs.Tristate `config:"use_x_id"`
|
||||
SignAcceptEncoding fs.Tristate `config:"sign_accept_encoding"`
|
||||
ObjectLockMode string `config:"object_lock_mode"`
|
||||
@@ -1133,7 +1115,6 @@ type Options struct {
|
||||
BypassGovernanceRetention bool `config:"bypass_governance_retention"`
|
||||
BucketObjectLockEnabled bool `config:"bucket_object_lock_enabled"`
|
||||
ObjectLockSetAfterUpload bool `config:"object_lock_set_after_upload"`
|
||||
ObjectLockSupported fs.Tristate `config:"object_lock_supported"`
|
||||
}
|
||||
|
||||
// Fs represents a remote s3 server
|
||||
@@ -1560,7 +1541,7 @@ func s3Connection(ctx context.Context, opt *Options, client *http.Client) (s3Cli
|
||||
fs.Debugf(nil, "Using v2 auth")
|
||||
if opt.Provider == "IBMCOS" && opt.IBMAPIKey != "" && opt.IBMInstanceID != "" {
|
||||
options = append(options, func(s3Opt *s3.Options) {
|
||||
s3Opt.HTTPSignerV4 = &IbmIamSigner{APIKey: opt.IBMAPIKey, InstanceID: opt.IBMInstanceID, IAMEndpoint: opt.IBMIAMEndpoint}
|
||||
s3Opt.HTTPSignerV4 = &IbmIamSigner{APIKey: opt.IBMAPIKey, InstanceID: opt.IBMInstanceID}
|
||||
})
|
||||
} else {
|
||||
options = append(options, func(s3Opt *s3.Options) {
|
||||
@@ -1740,7 +1721,6 @@ func setQuirks(opt *Options, provider *Provider) {
|
||||
set(&opt.UseUnsignedPayload, true, provider.Quirks.UseUnsignedPayload)
|
||||
set(&opt.UseXID, true, provider.Quirks.UseXID)
|
||||
set(&opt.SignAcceptEncoding, true, provider.Quirks.SignAcceptEncoding)
|
||||
set(&opt.ObjectLockSupported, true, provider.Quirks.ObjectLockSupported)
|
||||
}
|
||||
|
||||
// setRoot changes the root of the Fs
|
||||
@@ -4623,31 +4603,8 @@ func (o *Object) uploadMultipart(ctx context.Context, src fs.ObjectInfo, in io.R
|
||||
return wantETag, gotETag, versionID, s3cw.ui, nil
|
||||
}
|
||||
|
||||
// bufferForObjectLockMD5 buffers the body and computes Content-MD5 when
|
||||
// Object Lock parameters are set on the request. AWS S3 requires Content-MD5
|
||||
// for PutObject with Object Lock params and cannot compute it automatically
|
||||
// from a non-seekable io.Reader.
|
||||
// See: https://github.com/aws/aws-sdk-go-v2/discussions/2960
|
||||
func bufferForObjectLockMD5(req *s3.PutObjectInput, in io.Reader) (io.Reader, error) {
|
||||
if req.ObjectLockMode == "" && req.ObjectLockRetainUntilDate == nil && req.ObjectLockLegalHoldStatus == "" {
|
||||
return in, nil
|
||||
}
|
||||
buf, err := io.ReadAll(in)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read body for Content-MD5: %w", err)
|
||||
}
|
||||
md5sum := md5.Sum(buf)
|
||||
md5base64 := base64.StdEncoding.EncodeToString(md5sum[:])
|
||||
req.ContentMD5 = &md5base64
|
||||
return bytes.NewReader(buf), nil
|
||||
}
|
||||
|
||||
// Upload a single part using PutObject
|
||||
func (o *Object) uploadSinglepartPutObject(ctx context.Context, req *s3.PutObjectInput, size int64, in io.Reader) (etag string, lastModified time.Time, versionID *string, err error) {
|
||||
in, err = bufferForObjectLockMD5(req, in)
|
||||
if err != nil {
|
||||
return etag, lastModified, nil, err
|
||||
}
|
||||
req.Body = io.NopCloser(in)
|
||||
var options = []func(*s3.Options){}
|
||||
if o.fs.opt.UseUnsignedPayload.Value {
|
||||
@@ -4678,11 +4635,6 @@ func (o *Object) uploadSinglepartPutObject(ctx context.Context, req *s3.PutObjec
|
||||
|
||||
// Upload a single part using a presigned request
|
||||
func (o *Object) uploadSinglepartPresignedRequest(ctx context.Context, req *s3.PutObjectInput, size int64, in io.Reader) (etag string, lastModified time.Time, versionID *string, err error) {
|
||||
// Content-MD5 must be set before signing so it's included in the presigned URL.
|
||||
in, err = bufferForObjectLockMD5(req, in)
|
||||
if err != nil {
|
||||
return etag, lastModified, nil, err
|
||||
}
|
||||
// Create the presigned request
|
||||
putReq, err := s3.NewPresignClient(o.fs.c).PresignPutObject(ctx, req, s3.WithPresignExpires(15*time.Minute))
|
||||
if err != nil {
|
||||
|
||||
@@ -499,9 +499,6 @@ func (f *Fs) InternalTestVersions(t *testing.T) {
|
||||
}
|
||||
|
||||
func (f *Fs) InternalTestObjectLock(t *testing.T) {
|
||||
if !f.opt.ObjectLockSupported.Value {
|
||||
t.Skip("Object Lock not supported by this provider (quirk object_lock_supported = false)")
|
||||
}
|
||||
ctx := context.Background()
|
||||
|
||||
// Create a temporary bucket with Object Lock enabled to test on.
|
||||
@@ -724,55 +721,6 @@ func (f *Fs) InternalTestObjectLock(t *testing.T) {
|
||||
assert.WithinDuration(t, retainUntilDate, gotRetainDate, time.Second)
|
||||
assert.Equal(t, "ON", gotMetadata["object-lock-legal-hold-status"])
|
||||
})
|
||||
|
||||
t.Run("Multipart", func(t *testing.T) {
|
||||
// Force multipart upload by setting a very low cutoff
|
||||
oldCutoff := f.opt.UploadCutoff
|
||||
f.opt.UploadCutoff = fs.SizeSuffix(1)
|
||||
f.opt.ObjectLockMode = "GOVERNANCE"
|
||||
f.opt.ObjectLockRetainUntilDate = retainUntilDate.Format(time.RFC3339)
|
||||
defer func() {
|
||||
f.opt.UploadCutoff = oldCutoff
|
||||
f.opt.ObjectLockMode = ""
|
||||
f.opt.ObjectLockRetainUntilDate = ""
|
||||
}()
|
||||
|
||||
contents := random.String(100)
|
||||
item := fstest.NewItem("test-object-lock-multipart", contents, fstest.Time("2001-05-06T04:05:06.499999999Z"))
|
||||
obj := fstests.PutTestContents(ctx, t, f, &item, contents, true)
|
||||
defer func() {
|
||||
removeLocked(t, obj)
|
||||
}()
|
||||
|
||||
o := obj.(*Object)
|
||||
gotMetadata, err := o.Metadata(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "GOVERNANCE", gotMetadata["object-lock-mode"])
|
||||
})
|
||||
|
||||
t.Run("Presigned", func(t *testing.T) {
|
||||
// Use presigned request upload path
|
||||
f.opt.UsePresignedRequest = true
|
||||
f.opt.ObjectLockMode = "GOVERNANCE"
|
||||
f.opt.ObjectLockRetainUntilDate = retainUntilDate.Format(time.RFC3339)
|
||||
defer func() {
|
||||
f.opt.UsePresignedRequest = false
|
||||
f.opt.ObjectLockMode = ""
|
||||
f.opt.ObjectLockRetainUntilDate = ""
|
||||
}()
|
||||
|
||||
contents := random.String(100)
|
||||
item := fstest.NewItem("test-object-lock-presigned", contents, fstest.Time("2001-05-06T04:05:06.499999999Z"))
|
||||
obj := fstests.PutTestContents(ctx, t, f, &item, contents, true)
|
||||
defer func() {
|
||||
removeLocked(t, obj)
|
||||
}()
|
||||
|
||||
o := obj.(*Object)
|
||||
gotMetadata, err := o.Metadata(ctx)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, "GOVERNANCE", gotMetadata["object-lock-mode"])
|
||||
})
|
||||
}
|
||||
|
||||
func (f *Fs) InternalTest(t *testing.T) {
|
||||
|
||||
@@ -225,7 +225,6 @@ type Fs struct {
|
||||
hasOCMD5 bool // set if can use owncloud style checksums for MD5
|
||||
hasOCSHA1 bool // set if can use owncloud style checksums for SHA1
|
||||
hasMESHA1 bool // set if can use fastmail style checksums for SHA1
|
||||
useStandardProps bool // set if should use standard props for PROPFIND
|
||||
ntlmAuthMu sync.Mutex // mutex to serialize NTLM auth roundtrips
|
||||
chunksUploadURL string // upload URL for nextcloud chunked
|
||||
canChunk bool // set if nextcloud and nextcloud_chunk_size is set
|
||||
@@ -353,10 +352,7 @@ func (f *Fs) readMetaDataForPath(ctx context.Context, path string, depth string)
|
||||
}
|
||||
if f.hasOCMD5 || f.hasOCSHA1 {
|
||||
opts.Body = bytes.NewBuffer(owncloudProps)
|
||||
} else if f.useStandardProps {
|
||||
opts.Body = bytes.NewBuffer(standardProps)
|
||||
}
|
||||
// Note: According to WebDAV RFC 4918, empty PROPFIND body defaults to allprop
|
||||
var result api.Multistatus
|
||||
var resp *http.Response
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
@@ -715,7 +711,6 @@ func (f *Fs) setQuirks(ctx context.Context, vendor string) error {
|
||||
f.precision = time.Second
|
||||
f.useOCMtime = true
|
||||
case "other":
|
||||
f.useStandardProps = true
|
||||
default:
|
||||
fs.Debugf(f, "Unknown vendor %q", vendor)
|
||||
}
|
||||
@@ -764,23 +759,13 @@ var owncloudProps = []byte(`<?xml version="1.0"?>
|
||||
<d:getlastmodified />
|
||||
<d:getcontentlength />
|
||||
<d:resourcetype />
|
||||
<d:getcontenttype />
|
||||
<oc:checksums />
|
||||
<oc:permissions />
|
||||
</d:prop>
|
||||
</d:propfind>
|
||||
`)
|
||||
|
||||
var standardProps = []byte(`<?xml version="1.0"?>
|
||||
<d:propfind xmlns:d="DAV:">
|
||||
<d:prop>
|
||||
<d:displayname/>
|
||||
<d:getlastmodified/>
|
||||
<d:getcontentlength/>
|
||||
<d:resourcetype/>
|
||||
</d:prop>
|
||||
</d:propfind>
|
||||
`)
|
||||
|
||||
// list the objects into the function supplied
|
||||
//
|
||||
// If directories is set it only sends directories
|
||||
@@ -802,10 +787,7 @@ func (f *Fs) listAll(ctx context.Context, dir string, directoriesOnly bool, file
|
||||
}
|
||||
if f.hasOCMD5 || f.hasOCSHA1 {
|
||||
opts.Body = bytes.NewBuffer(owncloudProps)
|
||||
} else if f.useStandardProps {
|
||||
opts.Body = bytes.NewBuffer(standardProps)
|
||||
}
|
||||
// Note: According to WebDAV RFC 4918, empty PROPFIND body defaults to `allprop`
|
||||
var result api.Multistatus
|
||||
var resp *http.Response
|
||||
err = f.pacer.Call(func() (bool, error) {
|
||||
|
||||
+1
-12
@@ -98,26 +98,15 @@ func (b *bisyncRun) lockFileIsExpired() bool {
|
||||
rdf, err := os.Open(b.lockFile)
|
||||
b.handleErr(b.lockFile, "error reading lock file", err, true, true)
|
||||
dec := json.NewDecoder(rdf)
|
||||
var decodeErr error
|
||||
for {
|
||||
if err := dec.Decode(&b.lockFileOpt.data); err != nil {
|
||||
if err != io.EOF {
|
||||
decodeErr = err
|
||||
fs.Errorf(b.lockFile, "err: %v", err)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
b.handleErr(b.lockFile, "error closing file", rdf.Close(), true, true)
|
||||
if decodeErr != nil {
|
||||
if b.opt.MaxLock < basicallyforever {
|
||||
fs.Infof(b.lockFile, Color(terminal.YellowFg, "Lock file is unreadable (decode error: %v) and --max-lock is set. Treating as expired."), decodeErr)
|
||||
markFailed(b.listing1)
|
||||
markFailed(b.listing2)
|
||||
return true
|
||||
}
|
||||
fs.Errorf(b.lockFile, Color(terminal.RedFg, "Lock file exists, but contents are unreadable. (decode error: %v)"), decodeErr)
|
||||
return false
|
||||
}
|
||||
if !b.lockFileOpt.data.TimeExpires.IsZero() && b.lockFileOpt.data.TimeExpires.Before(time.Now()) {
|
||||
fs.Infof(b.lockFile, Color(terminal.GreenFg, "Lock file found, but it expired at %v. Will delete it and proceed."), b.lockFileOpt.data.TimeExpires)
|
||||
markFailed(b.listing1) // listing is untrusted so force revert to prior (if --recover) or create new ones (if --resync)
|
||||
|
||||
@@ -1,80 +0,0 @@
|
||||
package bisync
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func newTestLockfileBisyncRun(t *testing.T, lockContent string, maxLock fs.Duration) *bisyncRun {
|
||||
t.Helper()
|
||||
dir := t.TempDir()
|
||||
lockPath := filepath.Join(dir, "test.lck")
|
||||
require.NoError(t, os.WriteFile(lockPath, []byte(lockContent), 0600))
|
||||
|
||||
listing1 := filepath.Join(dir, "listing1")
|
||||
listing2 := filepath.Join(dir, "listing2")
|
||||
require.NoError(t, os.WriteFile(listing1, []byte(""), 0600))
|
||||
require.NoError(t, os.WriteFile(listing2, []byte(""), 0600))
|
||||
|
||||
return &bisyncRun{
|
||||
lockFile: lockPath,
|
||||
opt: &Options{MaxLock: maxLock},
|
||||
listing1: listing1,
|
||||
listing2: listing2,
|
||||
}
|
||||
}
|
||||
|
||||
func TestLockfileIsExpired_UnreadableWithMaxLock(t *testing.T) {
|
||||
b := newTestLockfileBisyncRun(t, "not json!!!", fs.Duration(5*time.Minute))
|
||||
assert.True(t, b.lockFileIsExpired(), "unreadable lockfile with --max-lock set should be treated as expired")
|
||||
}
|
||||
|
||||
func TestLockfileIsExpired_UnreadableWithoutMaxLock(t *testing.T) {
|
||||
b := newTestLockfileBisyncRun(t, "not json!!!", basicallyforever)
|
||||
assert.False(t, b.lockFileIsExpired(), "unreadable lockfile without --max-lock should not be treated as expired")
|
||||
}
|
||||
|
||||
func TestLockfileIsExpired_ValidExpired(t *testing.T) {
|
||||
data := struct {
|
||||
Session string
|
||||
PID string
|
||||
TimeRenewed time.Time
|
||||
TimeExpires time.Time
|
||||
}{
|
||||
Session: "test",
|
||||
PID: "12345",
|
||||
TimeRenewed: time.Now().Add(-10 * time.Minute),
|
||||
TimeExpires: time.Now().Add(-5 * time.Minute),
|
||||
}
|
||||
content, err := json.Marshal(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
b := newTestLockfileBisyncRun(t, string(content), fs.Duration(5*time.Minute))
|
||||
assert.True(t, b.lockFileIsExpired(), "valid lockfile with past expiry should be expired")
|
||||
}
|
||||
|
||||
func TestLockfileIsExpired_ValidNotExpired(t *testing.T) {
|
||||
data := struct {
|
||||
Session string
|
||||
PID string
|
||||
TimeRenewed time.Time
|
||||
TimeExpires time.Time
|
||||
}{
|
||||
Session: "test",
|
||||
PID: "12345",
|
||||
TimeRenewed: time.Now(),
|
||||
TimeExpires: time.Now().Add(10 * time.Minute),
|
||||
}
|
||||
content, err := json.Marshal(data)
|
||||
require.NoError(t, err)
|
||||
|
||||
b := newTestLockfileBisyncRun(t, string(content), fs.Duration(5*time.Minute))
|
||||
assert.False(t, b.lockFileIsExpired(), "valid lockfile with future expiry should not be expired")
|
||||
}
|
||||
+14
-16
@@ -1,8 +1,7 @@
|
||||
Rclone @ allows Linux, FreeBSD, macOS and Windows to
|
||||
mount any of Rclone's cloud storage systems as a file system with FUSE.
|
||||
|
||||
First set up your remote using `rclone config`. Check it works with `rclone ls`
|
||||
etc.
|
||||
First set up your remote using `rclone config`. Check it works with `rclone ls` etc.
|
||||
|
||||
On Linux and macOS, you can run mount in either foreground or background (aka
|
||||
daemon) mode. Mount runs in foreground mode by default. Use the `--daemon` flag
|
||||
@@ -30,8 +29,8 @@ The following examples will mount to an automatically assigned drive,
|
||||
to specific drive letter `X:`, to path `C:\path\parent\mount`
|
||||
(where parent directory or drive must exist, and mount must **not** exist,
|
||||
and is not supported when [mounting as a network drive](#mounting-modes-on-windows)),
|
||||
and the last example will mount as network share `\\cloud\remote` and map it to
|
||||
an automatically assigned drive:
|
||||
and the last example will mount as network share `\\cloud\remote` and map it to an
|
||||
automatically assigned drive:
|
||||
|
||||
```console
|
||||
rclone @ remote:path/to/files *
|
||||
@@ -137,8 +136,8 @@ rclone @ remote:path/to/files X: --volname \\server\share
|
||||
|
||||
You may also specify the network share UNC path as the mountpoint itself. Then rclone
|
||||
will automatically assign a drive letter, same as with `*` and use that as
|
||||
mountpoint, and instead use the UNC path specified as the volume name, as if it
|
||||
were specified with the `--volname` option. This will also implicitly set
|
||||
mountpoint, and instead use the UNC path specified as the volume name, as if it were
|
||||
specified with the `--volname` option. This will also implicitly set
|
||||
the `--network-mode` option. This means the following two examples have same result:
|
||||
|
||||
```console
|
||||
@@ -269,7 +268,7 @@ does not suffer from the same limitations.
|
||||
|
||||
Mounting on macOS can be done either via [built-in NFS server](/commands/rclone_serve_nfs/),
|
||||
[macFUSE](https://osxfuse.github.io/) (also known as osxfuse) or
|
||||
[FUSE-T](https://www.fuse-t.org/). macFUSE is a traditional FUSE driver utilizing
|
||||
[FUSE-T](https://www.fuse-t.org/).macFUSE is a traditional FUSE driver utilizing
|
||||
a macOS kernel extension (kext). FUSE-T is an alternative FUSE system which
|
||||
"mounts" via an NFSv4 local server.
|
||||
|
||||
@@ -312,13 +311,13 @@ current as of FUSE-T version 1.0.14.
|
||||
|
||||
As per the [FUSE-T wiki](https://github.com/macos-fuse-t/fuse-t/wiki#caveats):
|
||||
|
||||
> File access and modification times cannot be set separately as it seems to be
|
||||
> an issue with the NFS client which always modifies both. Can be reproduced
|
||||
> with `touch -m` and `touch -a` commands
|
||||
> File access and modification times cannot be set separately as it seems to be an
|
||||
> issue with the NFS client which always modifies both. Can be reproduced with
|
||||
> 'touch -m' and 'touch -a' commands
|
||||
|
||||
This means that viewing files with various tools, notably macOS Finder, will
|
||||
cause rlcone to update the modification time of the file. This may make rclone
|
||||
upload a full new copy of the file.
|
||||
This means that viewing files with various tools, notably macOS Finder, will cause
|
||||
rlcone to update the modification time of the file. This may make rclone upload a
|
||||
full new copy of the file.
|
||||
|
||||
##### Read Only mounts
|
||||
|
||||
@@ -332,10 +331,9 @@ On newer versions of Ubuntu, you may encounter the following error when running
|
||||
|
||||
> NOTICE: mount helper error: fusermount3: mount failed: Permission denied
|
||||
> CRITICAL: Fatal error: failed to mount FUSE fs: fusermount: exit status 1
|
||||
|
||||
This may be due to newer [Apparmor](https://wiki.ubuntu.com/AppArmor) restrictions,
|
||||
which can be disabled with `sudo aa-disable /usr/bin/fusermount3` (you may need
|
||||
to `sudo apt install apparmor-utils` beforehand).
|
||||
which can be disabled with `sudo aa-disable /usr/bin/fusermount3` (you may need to
|
||||
`sudo apt install apparmor-utils` beforehand).
|
||||
|
||||
### Limitations
|
||||
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
}
|
||||
},
|
||||
"highlight": {
|
||||
"noClasses": false
|
||||
"style": "monokailight"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ notoc: true
|
||||
# Rclone syncs your files to cloud storage
|
||||
|
||||
<!-- markdownlint-disable-next-line line-length -->
|
||||
{{< img width="50%" src="/img/logo_on_light__horizontal_color.svg" dark-src="/img/logo_on_dark__horizontal_color.svg" alt="rclone logo" style="float:right; padding: 5px;" class="hide-mobile" >}}
|
||||
{{< img width="50%" src="/img/logo_on_light__horizontal_color.svg" alt="rclone logo" style="float:right; padding: 5px;" >}}
|
||||
|
||||
- [About rclone](#about)
|
||||
- [What can rclone do for you?](#what)
|
||||
@@ -216,7 +216,6 @@ WebDAV or S3, that work out of the box.)
|
||||
{{< provider name="SugarSync" home="https://sugarsync.com/" config="/sugarsync/" >}}
|
||||
{{< provider name="Tencent Cloud Object Storage (COS)" home="https://intl.cloud.tencent.com/product/cos" config="/s3/#tencent-cos" >}}
|
||||
{{< provider name="Uloz.to" home="https://uloz.to" config="/ulozto/" >}}
|
||||
{{< provider name="US3" home="https://www.ucloud.cn/site/product/ufile.html" config="/s3/#us3" >}}
|
||||
{{< provider name="Wasabi" home="https://wasabi.com/" config="/s3/#wasabi" >}}
|
||||
{{< provider name="WebDAV" home="https://en.wikipedia.org/wiki/WebDAV" config="/webdav/" >}}
|
||||
{{< provider name="Yandex Disk" home="https://disk.yandex.com/" config="/yandex/" >}}
|
||||
@@ -249,7 +248,7 @@ These backends adapt or modify other storage providers:
|
||||
|
||||
## Links
|
||||
|
||||
- [Home page](https://rclone.org/)
|
||||
- [GitHub project page for source and bug tracker](https://github.com/rclone/rclone)
|
||||
- [Rclone Forum](https://forum.rclone.org)
|
||||
- [Downloads](/downloads/)
|
||||
- {{< icon "fa fa-home fa-fw" >}} [Home page](https://rclone.org/)
|
||||
- {{< icon "fab fa-github fa-fw" >}} [GitHub project page for source and bug tracker](https://github.com/rclone/rclone)
|
||||
- {{< icon "fa fa-comments fa-fw" >}} [Rclone Forum](https://forum.rclone.org)
|
||||
- {{< icon "fas fa-cloud-download-alt fa-fw" >}}[Downloads](/downloads/)
|
||||
@@ -4,7 +4,7 @@ description: "Remote Aliases"
|
||||
versionIntroduced: "v1.40"
|
||||
---
|
||||
|
||||
# Alias
|
||||
# {{< icon "fa fa-link" >}} Alias
|
||||
|
||||
The `alias` remote provides a new name for another remote.
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ versionIntroduced: "v1.20"
|
||||
status: Removed
|
||||
---
|
||||
|
||||
# Amazon Drive
|
||||
# {{< icon "fab fa-amazon" >}} Amazon Drive
|
||||
|
||||
Amazon Drive, formerly known as Amazon Cloud Drive, was a cloud storage
|
||||
service run by Amazon for consumers.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Archive Remote"
|
||||
versionIntroduced: "v1.72"
|
||||
---
|
||||
|
||||
# Archive
|
||||
# {{< icon "fas fa-archive" >}} Archive
|
||||
|
||||
The Archive backend allows read only access to the content of archive
|
||||
files on cloud storage without downloading the complete archive. This
|
||||
|
||||
@@ -1095,17 +1095,3 @@ put them back in again. -->
|
||||
- razorloves <razorloves@gmail.com>
|
||||
- Duncan F <131309315+duncanaf@users.noreply.github.com>
|
||||
- Billy Hughes <w.g.h.hughes@gmail.com>
|
||||
- Bhagyashreek8 <57988406+Bhagyashreek8@users.noreply.github.com>
|
||||
- Andriy Senyshyn <135705861+sam-mt@users.noreply.github.com>
|
||||
- Andrew Furman <7343697+furmandev@users.noreply.github.com>
|
||||
- ZRHan <56144550+ZRHann@users.noreply.github.com>
|
||||
- Jason <jasonbabo@gmail.com>
|
||||
- Patrick Farrell <pfarrell@whamcloud.com>
|
||||
- BizaNator <17164422+BizaNator@users.noreply.github.com>
|
||||
- lif <1835304752@qq.com>
|
||||
- jinkeyuu <44105232+jinkeyuu@users.noreply.github.com>
|
||||
- jinyu.han <jinyu.han@ucloud.cn>
|
||||
- Claude Opus 4.6 <noreply@anthropic.com>
|
||||
- Andriy Senyshyn <andriy.senyshyn@kiteworks.com>
|
||||
- Mike GIllan <mike.gillan@gmail.com>
|
||||
- Xiangzhe <xiangzhedev@gmail.com>
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Microsoft Azure Blob Storage"
|
||||
versionIntroduced: "v1.38"
|
||||
---
|
||||
|
||||
# Microsoft Azure Blob Storage
|
||||
# {{< icon "fab fa-windows" >}} Microsoft Azure Blob Storage
|
||||
|
||||
Paths are specified as `remote:container` (or `remote:` for the `lsd`
|
||||
command.) You may put subdirectories in too, e.g.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Microsoft Azure Files Storage"
|
||||
versionIntroduced: "v1.65"
|
||||
---
|
||||
|
||||
# Microsoft Azure Files Storage
|
||||
# {{< icon "fab fa-windows" >}} Microsoft Azure Files Storage
|
||||
|
||||
Paths are specified as `remote:` You may put subdirectories in too,
|
||||
e.g. `remote:path/to/dir`.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ description: "Backblaze B2"
|
||||
versionIntroduced: "v1.26"
|
||||
---
|
||||
|
||||
# Backblaze B2
|
||||
# {{< icon "fa fa-fire" >}} Backblaze B2
|
||||
|
||||
B2 is [Backblaze's cloud storage system](https://www.backblaze.com/cloud-storage).
|
||||
|
||||
|
||||
@@ -820,12 +820,6 @@ running -- and you can therefore be reasonably sure that any *expired* lock
|
||||
file you may find was left there by an interrupted run, not one that is still
|
||||
running and just taking awhile.
|
||||
|
||||
If a lock file exists but its contents are unreadable (for example, due to an
|
||||
incomplete write or disk error), it is treated as expired when `--max-lock` is
|
||||
set to a value greater than `0`. If `--max-lock` is `0` or not set, an
|
||||
unreadable lock file will produce an error and block future runs until removed
|
||||
manually.
|
||||
|
||||
If `--max-lock` is `0` or not set, the default is that lock files will never
|
||||
expire, and will block future runs (of these same two bisync paths)
|
||||
indefinitely.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ description: "Rclone docs for Box"
|
||||
versionIntroduced: "v1.38"
|
||||
---
|
||||
|
||||
# Box
|
||||
# {{< icon "fa fa-archive" >}} Box
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for cache remote"
|
||||
versionIntroduced: "v1.39"
|
||||
---
|
||||
|
||||
# Cache
|
||||
# {{< icon "fa fa-archive" >}} Cache
|
||||
|
||||
The `cache` remote wraps another existing remote and stores file structure
|
||||
and its data for long running tasks like `rclone mount`.
|
||||
|
||||
@@ -6,22 +6,6 @@ description: "Rclone Changelog"
|
||||
|
||||
# Changelog
|
||||
|
||||
## v1.73.3 - 2026-03-23
|
||||
|
||||
[See commits](https://github.com/rclone/rclone/compare/v1.73.2...v1.73.3)
|
||||
|
||||
- Bug Fixes
|
||||
- build
|
||||
- Update to google.golang.org/grpc 1.79.3 to fix CVE-2026-33186 (dependabot[bot])
|
||||
- Update to github.com/buger/jsonparser 1.1.2 to fix GHSA-6g7g-w4f8-9c9x (dependabot[bot])
|
||||
- doc fixes
|
||||
- Added text to the label showing version-introduced info (Jan-Philipp Reßler)
|
||||
- Clarify Filen password change requires updating both password and API key in rclone config (Jason)
|
||||
- s3: clarify multi tenant support for Cubbit (Marco Ferretti)
|
||||
- jottacloud: Fix broken link (albertony)
|
||||
- lib/rest: Fix URLPathEscapeAll breaking WebDAV servers (eg nzbdav) with strict path matching (Andrew Furman)
|
||||
- list: Fix nil pointer panic in Sorter when temp file creation fails (Nick Craig-Wood)
|
||||
|
||||
## v1.73.2 - 2026-03-06
|
||||
|
||||
[See commits](https://github.com/rclone/rclone/compare/v1.73.1...v1.73.2)
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Split-chunking overlay remote"
|
||||
versionIntroduced: "v1.50"
|
||||
---
|
||||
|
||||
# Chunker
|
||||
# {{< icon "fa fa-cut" >}} Chunker
|
||||
|
||||
The `chunker` overlay transparently splits large files into smaller chunks
|
||||
during upload to wrapped remote and transparently assembles them back
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Cloudinary backend"
|
||||
versionIntroduced: "v1.69"
|
||||
|
||||
---
|
||||
# Cloudinary
|
||||
# {{< icon "fa fa-cloud" >}} Cloudinary
|
||||
|
||||
This is a backend for the [Cloudinary](https://cloudinary.com/) platform
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Combine several remotes into one"
|
||||
versionIntroduced: "v1.59"
|
||||
---
|
||||
|
||||
# Combine
|
||||
# {{< icon "fa fa-folder-plus" >}} Combine
|
||||
|
||||
The `combine` backend joins remotes together into a single directory
|
||||
tree.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Compression Remote"
|
||||
versionIntroduced: "v1.54"
|
||||
---
|
||||
|
||||
# Compress
|
||||
# {{< icon "fas fa-compress" >}} Compress
|
||||
|
||||
## Warning
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Encryption overlay remote"
|
||||
versionIntroduced: "v1.33"
|
||||
---
|
||||
|
||||
# Crypt
|
||||
# {{< icon "fa fa-lock" >}} Crypt
|
||||
|
||||
Rclone `crypt` remotes encrypt and decrypt other remotes.
|
||||
|
||||
|
||||
+17
-18
@@ -753,21 +753,21 @@ object also.
|
||||
Here is a table of standard system metadata which, if appropriate, a
|
||||
backend may implement.
|
||||
|
||||
| key | description | example |
|
||||
| --- | ----------- | ------- |
|
||||
| mode | File type and mode: octal, unix style | 0100664 |
|
||||
| uid | User ID of owner: decimal number | 500 |
|
||||
| gid | Group ID of owner: decimal number | 500 |
|
||||
| rdev | Device ID (if special file) => hexadecimal | 0 |
|
||||
| atime | Time of last access: RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| mtime | Time of last modification: RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| btime | Time of file creation (birth): RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| utime | Time of file upload: RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| cache-control | Cache-Control header | no-cache |
|
||||
| key | description | example |
|
||||
|---------------------|-------------|---------|
|
||||
| mode | File type and mode: octal, unix style | 0100664 |
|
||||
| uid | User ID of owner: decimal number | 500 |
|
||||
| gid | Group ID of owner: decimal number | 500 |
|
||||
| rdev | Device ID (if special file) => hexadecimal | 0 |
|
||||
| atime | Time of last access: RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| mtime | Time of last modification: RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| btime | Time of file creation (birth): RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| utime | Time of file upload: RFC 3339 | 2006-01-02T15:04:05.999999999Z07:00 |
|
||||
| cache-control | Cache-Control header | no-cache |
|
||||
| content-disposition | Content-Disposition header | inline |
|
||||
| content-encoding | Content-Encoding header | gzip |
|
||||
| content-language | Content-Language header | en-US |
|
||||
| content-type | Content-Type header | text/plain |
|
||||
| content-encoding | Content-Encoding header | gzip |
|
||||
| content-language | Content-Language header | en-US |
|
||||
| content-type | Content-Type header | text/plain |
|
||||
|
||||
The metadata keys `mtime` and `content-type` will take precedence if
|
||||
supplied in the metadata over reading the `Content-Type` or
|
||||
@@ -1193,8 +1193,7 @@ on any OS, and the value is defined as following:
|
||||
|
||||
- On Windows: `%HOME%` if defined, else `%USERPROFILE%`, or else `%HOMEDRIVE%\%HOMEPATH%`.
|
||||
- On Unix: `$HOME` if defined, else by looking up current user in OS-specific user
|
||||
database (e.g. passwd file), or else use the result from shell command
|
||||
`cd && pwd`.
|
||||
database (e.g. passwd file), or else use the result from shell command `cd && pwd`.
|
||||
|
||||
If you run `rclone config file` you will see where the default location is for
|
||||
you. Running `rclone config touch` will ensure a configuration file exists,
|
||||
@@ -2060,7 +2059,7 @@ This is the default.
|
||||
`CAUTIOUS` will try to prevent rclone from reaching the limit. Only applicable
|
||||
for `--max-transfer`.
|
||||
|
||||
### -M, --metadata
|
||||
## -M, --metadata
|
||||
|
||||
Setting this flag enables rclone to copy the metadata from the source
|
||||
to the destination. For local backends this is ownership, permissions,
|
||||
@@ -3445,7 +3444,7 @@ many items, the input is treated as a [CSV encoded](https://godoc.org/encoding/c
|
||||
string. For example
|
||||
|
||||
| Environment variable | Equivalent options |
|
||||
| -------------------- | ------------------ |
|
||||
|----------------------|--------------------|
|
||||
| `RCLONE_EXCLUDE="*.jpg"` | `--exclude "*.jpg"` |
|
||||
| `RCLONE_EXCLUDE="*.jpg,*.png"` | `--exclude "*.jpg"` `--exclude "*.png"` |
|
||||
| `RCLONE_EXCLUDE='"*.jpg","*.png"'` | `--exclude "*.jpg"` `--exclude "*.png"` |
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ description: "Rclone docs for DOI"
|
||||
versionIntroduced: "v1.70"
|
||||
---
|
||||
|
||||
# DOI
|
||||
# {{< icon "fa fa-building-columns" >}} DOI
|
||||
|
||||
The DOI remote is a read only remote for reading files from digital object
|
||||
identifiers (DOI).
|
||||
|
||||
@@ -16,7 +16,7 @@ image](https://securebuild.com/images/rclone) through our partner
|
||||
## Release {{% version %}} OS requirements {#osrequirements}
|
||||
|
||||
| OS | Minimum Version |
|
||||
| :---: | :---: |
|
||||
|:-------:|:-------:|
|
||||
| Linux | Kernel 3.2 |
|
||||
| macOS | 12 (Monterey) |
|
||||
| Windows | 10, Server 2016 |
|
||||
@@ -31,7 +31,7 @@ in the Go Wiki.
|
||||
## Release {{% version %}} {#release}
|
||||
|
||||
| Arch-OS | Windows | macOS | Linux | .deb | .rpm | FreeBSD | NetBSD | OpenBSD | Plan9 | Solaris |
|
||||
| :-----: | :-----: | :---: | :---: | :--: | :--: | :-----: | :----: | :-----: | :---: | :-----: |
|
||||
|:-------:|:-------:|:-----:|:-----:|:----:|:----:|:-------:|:------:|:-------:|:-----:|:-------:|
|
||||
| Intel/AMD - 64 Bit | {{< download windows amd64 >}} | {{< download osx amd64 >}} | {{< download linux amd64 >}} | {{< download linux amd64 deb >}} | {{< download linux amd64 rpm >}} | {{< download freebsd amd64 >}} | {{< download netbsd amd64 >}} | {{< download openbsd amd64 >}} | {{< download plan9 amd64 >}} | {{< download solaris amd64 >}} |
|
||||
| Intel/AMD - 32 Bit | {{< download windows 386 >}} | - | {{< download linux 386 >}} | {{< download linux 386 deb >}} | {{< download linux 386 rpm >}} | {{< download freebsd 386 >}} | {{< download netbsd 386 >}} | {{< download openbsd 386 >}} | {{< download plan9 386 >}} | - |
|
||||
| ARMv5 - 32 Bit NOHF | - | - | {{< download linux arm >}} | {{< download linux arm deb >}} | {{< download linux arm rpm >}} | {{< download freebsd arm >}} | {{< download netbsd arm >}} | - | - | - |
|
||||
@@ -120,7 +120,7 @@ If you would like to download the current version (maybe from a
|
||||
script) from a URL which doesn't change then you can use these links.
|
||||
|
||||
| Arch-OS | Windows | macOS | Linux | .deb | .rpm | FreeBSD | NetBSD | OpenBSD | Plan9 | Solaris |
|
||||
| :-----: | :-----: | :---: | :---: | :--: | :--: | :-----: | :----: | :-----: | :---: | :-----: |
|
||||
|:-------:|:-------:|:-----:|:-----:|:----:|:----:|:-------:|:------:|:-------:|:-----:|:-------:|
|
||||
| Intel/AMD - 64 Bit | {{< cdownload windows amd64 >}} | {{< cdownload osx amd64 >}} | {{< cdownload linux amd64 >}} | {{< cdownload linux amd64 deb >}} | {{< cdownload linux amd64 rpm >}} | {{< cdownload freebsd amd64 >}} | {{< cdownload netbsd amd64 >}} | {{< cdownload openbsd amd64 >}} | {{< cdownload plan9 amd64 >}} | {{< cdownload solaris amd64 >}} |
|
||||
| Intel/AMD - 32 Bit | {{< cdownload windows 386 >}} | - | {{< cdownload linux 386 >}} | {{< cdownload linux 386 deb >}} | {{< cdownload linux 386 rpm >}} | {{< cdownload freebsd 386 >}} | {{< cdownload netbsd 386 >}} | {{< cdownload openbsd 386 >}} | {{< cdownload plan9 386 >}} | - |
|
||||
| ARMv5 - 32 Bit NOHF | - | - | {{< cdownload linux arm >}} | {{< cdownload linux arm deb >}} | {{< cdownload linux arm rpm >}} | {{< cdownload freebsd arm >}} | {{< cdownload netbsd arm >}} | - | - | - |
|
||||
@@ -137,13 +137,12 @@ Older downloads can be found at <https://downloads.rclone.org/>
|
||||
The latest `rclone` version working for:
|
||||
|
||||
| OS | Maximum rclone version |
|
||||
| :---: | :---: |
|
||||
|:-------:|:-------:|
|
||||
| Windows 7 | v1.63.1 |
|
||||
| Windows Server 2008 | v1.63.1 |
|
||||
| Windows Server 2012 | v1.63.1 |
|
||||
| Windows XP | v1.42 |
|
||||
| Windows Vista | v1.42 |
|
||||
| macOS 10.15 (Catalina) | v1.70.3 |
|
||||
| macOS 10.14 (Mojave) | v1.63.1 |
|
||||
| macOS 10.13 (High Sierra) | v1.63.1 |
|
||||
| macOS 10.12 (Sierra) | v1.56.0 |
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Drime"
|
||||
versionIntroduced: "v1.73"
|
||||
---
|
||||
|
||||
# Drime
|
||||
# {{< icon "fa fa-cloud" >}} Drime
|
||||
|
||||
[Drime](https://drime.cloud/) is a cloud storage and transfer service focused
|
||||
on fast, resilient file delivery. It offers both free and paid tiers with
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Google drive"
|
||||
versionIntroduced: "v0.91"
|
||||
---
|
||||
|
||||
# Google Drive
|
||||
# {{< icon "fab fa-google" >}} Google Drive
|
||||
|
||||
Paths are specified as `drive:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Dropbox"
|
||||
versionIntroduced: "v1.02"
|
||||
---
|
||||
|
||||
# Dropbox
|
||||
# {{< icon "fab fa-dropbox" >}} Dropbox
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for 1Fichier"
|
||||
versionIntroduced: "v1.49"
|
||||
---
|
||||
|
||||
# 1Fichier
|
||||
# {{< icon "fa fa-archive" >}} 1Fichier
|
||||
|
||||
This is a backend for the [1fichier](https://1fichier.com) cloud
|
||||
storage service. Note that a Premium subscription is required to use
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for the Enterprise File Fabric backend"
|
||||
versionIntroduced: "v1.54"
|
||||
---
|
||||
|
||||
# Enterprise File Fabric
|
||||
# {{< icon "fa fa-cloud" >}} Enterprise File Fabric
|
||||
|
||||
This backend supports [Storage Made Easy's Enterprise File
|
||||
Fabric™](https://storagemadeeasy.com/about/) which provides a software
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for FileLu"
|
||||
versionIntroduced: "v1.70"
|
||||
---
|
||||
|
||||
# FileLu
|
||||
# {{< icon "fa fa-folder" >}} FileLu
|
||||
|
||||
[FileLu](https://filelu.com/) is a reliable cloud storage provider
|
||||
offering features like secure file uploads, downloads, flexible
|
||||
|
||||
@@ -4,14 +4,12 @@ description: "Rclone docs for Filen"
|
||||
versionIntroduced: "1.73"
|
||||
---
|
||||
|
||||
# Filen
|
||||
# {{< icon "fa fa-solid fa-f" >}} Filen
|
||||
## Configuration
|
||||
The initial setup for Filen requires that you get an API key for your account,
|
||||
currently this is only possible using the [Filen CLI](https://github.com/FilenCloudDienste/filen-cli).
|
||||
This means you must first download the CLI, login, and then run the `export-api-key` command.
|
||||
|
||||
**Note:** If you change your Filen account password, you will need to update your rclone configuration with the new password and a re-exported API key (via `export-api-key`).
|
||||
|
||||
Here is an example of how to make a remote called `FilenRemote`. First run:
|
||||
|
||||
rclone config
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Files.com"
|
||||
versionIntroduced: "v1.68"
|
||||
---
|
||||
|
||||
# Files.com
|
||||
# {{< icon "fa fa-brands fa-files-pinwheel" >}} Files.com
|
||||
|
||||
[Files.com](https://www.files.com/) is a cloud storage service that provides a
|
||||
secure and easy way to store and share files.
|
||||
|
||||
+22
-22
@@ -202,28 +202,28 @@ them into regular expressions.
|
||||
|
||||
## Filter pattern examples {#examples}
|
||||
|
||||
| Description | Pattern | Matches | Does not match |
|
||||
| ----------- | ---------------- | ------------------------------- | ------------------ |
|
||||
| Wildcard | `*.jpg` | `/file.jpg` | `/file.png` |
|
||||
| | | `/dir/file.jpg` | `/dir/file.png` |
|
||||
| Rooted | `/*.jpg` | `/file.jpg` | `/file.png` |
|
||||
| | | `/file2.jpg` | `/dir/file.jpg` |
|
||||
| Alternates | `*.{jpg,png}` | `/file.jpg` | `/file.gif` |
|
||||
| | | `/dir/file.png` | `/dir/file.gif` |
|
||||
| Path Wildcard | `dir/**` | `/dir/anyfile` | `file.png` |
|
||||
| | | `/subdir/dir/subsubdir/anyfile` | `/subdir/file.png` |
|
||||
| Any Char | `*.t?t` | `/file.txt` | `/file.qxt` |
|
||||
| | | `/dir/file.tzt` | `/dir/file.png` |
|
||||
| Range | `*.[a-z]` | `/file.a` | `/file.0` |
|
||||
| | | `/dir/file.b` | `/dir/file.1` |
|
||||
| Escape | `*.\?\?\?` | `/file.???` | `/file.abc` |
|
||||
| | | `/dir/file.???` | `/dir/file.def` |
|
||||
| Class | `*.\d\d\d` | `/file.012` | `/file.abc` |
|
||||
| | | `/dir/file.345` | `/dir/file.def` |
|
||||
| Regexp | `*.{{jpe?g}}` | `/file.jpeg` | `/file.png` |
|
||||
| | | `/dir/file.jpg` | `/dir/file.jpeeg` |
|
||||
| Rooted Regexp | `/{{.*\.jpe?g}}` | `/file.jpeg` | `/file.png` |
|
||||
| | | `/file.jpg` | `/dir/file.jpg` |
|
||||
| Description | Pattern | Matches | Does not match |
|
||||
| ----------- |-------- | ------- | -------------- |
|
||||
| Wildcard | `*.jpg` | `/file.jpg` | `/file.png` |
|
||||
| | | `/dir/file.jpg` | `/dir/file.png` |
|
||||
| Rooted | `/*.jpg` | `/file.jpg` | `/file.png` |
|
||||
| | | `/file2.jpg` | `/dir/file.jpg` |
|
||||
| Alternates | `*.{jpg,png}` | `/file.jpg` | `/file.gif` |
|
||||
| | | `/dir/file.png` | `/dir/file.gif` |
|
||||
| Path Wildcard | `dir/**` | `/dir/anyfile` | `file.png` |
|
||||
| | | `/subdir/dir/subsubdir/anyfile` | `/subdir/file.png` |
|
||||
| Any Char | `*.t?t` | `/file.txt` | `/file.qxt` |
|
||||
| | | `/dir/file.tzt` | `/dir/file.png` |
|
||||
| Range | `*.[a-z]` | `/file.a` | `/file.0` |
|
||||
| | | `/dir/file.b` | `/dir/file.1` |
|
||||
| Escape | `*.\?\?\?` | `/file.???` | `/file.abc` |
|
||||
| | | `/dir/file.???` | `/dir/file.def` |
|
||||
| Class | `*.\d\d\d` | `/file.012` | `/file.abc` |
|
||||
| | | `/dir/file.345` | `/dir/file.def` |
|
||||
| Regexp | `*.{{jpe?g}}` | `/file.jpeg` | `/file.png` |
|
||||
| | | `/dir/file.jpg` | `/dir/file.jpeeg` |
|
||||
| Rooted Regexp | `/{{.*\.jpe?g}}` | `/file.jpeg` | `/file.png` |
|
||||
| | | `/file.jpg` | `/dir/file.jpg` |
|
||||
|
||||
## How filter rules are applied to files {#how-filter-rules-work}
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ description: "Rclone docs for FTP backend"
|
||||
versionIntroduced: "v1.37"
|
||||
---
|
||||
|
||||
# FTP
|
||||
# {{< icon "fa fa-file" >}} FTP
|
||||
|
||||
FTP is the File Transfer Protocol. Rclone FTP support is provided using the
|
||||
[github.com/jlaffaye/ftp](https://godoc.org/github.com/jlaffaye/ftp)
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Gofile"
|
||||
versionIntroduced: "v1.68"
|
||||
---
|
||||
|
||||
# Gofile
|
||||
# {{< icon "fa fa-folder" >}} Gofile
|
||||
|
||||
[Gofile](https://gofile.io) is a content storage and distribution
|
||||
platform. Its aim is to provide as much service as possible for free
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Google Cloud Storage"
|
||||
versionIntroduced: "v1.02"
|
||||
---
|
||||
|
||||
# Google Cloud Storage
|
||||
# {{< icon "fab fa-google" >}} Google Cloud Storage
|
||||
|
||||
Paths are specified as `remote:bucket` (or `remote:` for the `lsd`
|
||||
command.) You may put subdirectories in too, e.g. `remote:bucket/path/to/dir`.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Google Photos"
|
||||
versionIntroduced: "v1.49"
|
||||
---
|
||||
|
||||
# Google Photos
|
||||
# {{< icon "fa fa-images" >}} Google Photos
|
||||
|
||||
The rclone backend for [Google Photos](https://www.google.com/photos/about/) is
|
||||
a specialized backend for transferring photos and videos to and from
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Better checksums for other remotes"
|
||||
versionIntroduced: "v1.57"
|
||||
---
|
||||
|
||||
# Hasher
|
||||
# {{< icon "fa fa-check-double" >}} Hasher
|
||||
|
||||
Hasher is a special overlay backend to create remotes which handle
|
||||
checksums for other remotes. It's main functions include:
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Remote for Hadoop Distributed Filesystem"
|
||||
versionIntroduced: "v1.54"
|
||||
---
|
||||
|
||||
# HDFS
|
||||
# {{< icon "fa fa-globe" >}} HDFS
|
||||
|
||||
[HDFS](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-hdfs/HdfsDesign.html)
|
||||
is a distributed file-system, part of the [Apache Hadoop](https://hadoop.apache.org/)
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for HiDrive"
|
||||
versionIntroduced: "v1.59"
|
||||
---
|
||||
|
||||
# HiDrive
|
||||
# {{< icon "fa fa-cloud" >}} HiDrive
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Read only remote for HTTP servers"
|
||||
versionIntroduced: "v1.37"
|
||||
---
|
||||
|
||||
# HTTP
|
||||
# {{< icon "fa fa-globe" >}} HTTP
|
||||
|
||||
The HTTP remote is a read only remote for reading files of a
|
||||
webserver. The webserver should provide file listings which rclone
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for iCloud Drive"
|
||||
versionIntroduced: "v1.69"
|
||||
---
|
||||
|
||||
# iCloud Drive
|
||||
# {{< icon "fa fa-cloud" >}} iCloud Drive
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -12,27 +12,13 @@ The initial setup for an iCloud Drive backend involves getting a trust token/ses
|
||||
This can be done by simply using the regular iCloud password, and accepting the code
|
||||
prompt on another iCloud connected device.
|
||||
|
||||
**IMPORTANT**: App-specific passwords are not accepted. Only use your
|
||||
regular Apple ID password and 2FA.
|
||||
**IMPORTANT**: At the moment an app specific password won't be accepted. Only
|
||||
use your regular password and 2FA.
|
||||
|
||||
`rclone config` walks you through the token creation. The trust token is valid
|
||||
for 30 days. After which you will have to reauthenticate with `rclone reconnect`
|
||||
or `rclone config`.
|
||||
|
||||
## Authentication
|
||||
|
||||
rclone authenticates with Apple using [SRP (Secure Remote Password)](https://en.wikipedia.org/wiki/Secure_Remote_Password_protocol),
|
||||
the same protocol used by the iCloud web interface. Your password is never
|
||||
sent to Apple's servers -- instead, a cryptographic proof is exchanged that
|
||||
verifies you know the password without revealing it.
|
||||
|
||||
The authentication flow is:
|
||||
|
||||
1. rclone initiates a session with Apple's identity service
|
||||
2. An SRP key exchange takes place (your password is used locally to derive a key)
|
||||
3. Apple sends a 2FA prompt to your trusted devices
|
||||
4. After you enter the 2FA code, rclone receives a trust token for future sessions
|
||||
|
||||
Here is an example of how to make a remote called `iclouddrive`. First run:
|
||||
|
||||
```console
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for ImageKit backend."
|
||||
versionIntroduced: "v1.63"
|
||||
---
|
||||
|
||||
# ImageKit
|
||||
# {{< icon "fa fa-cloud" >}} ImageKit
|
||||
|
||||
This is a backend for the [ImageKit.io](https://imagekit.io/) storage service.
|
||||
|
||||
|
||||
+22
-22
@@ -285,8 +285,8 @@ rclone v1.49.1
|
||||
- go version: go1.12.9
|
||||
```
|
||||
|
||||
There are a few command line options to consider when starting an rclone Docker
|
||||
container from the rclone image.
|
||||
There are a few command line options to consider when starting an rclone Docker container
|
||||
from the rclone image.
|
||||
|
||||
- You need to mount the host rclone config dir at `/config/rclone` into the Docker
|
||||
container. Due to the fact that rclone updates tokens inside its config file,
|
||||
@@ -300,8 +300,8 @@ container from the rclone image.
|
||||
data files reside on the host with a non-root UID:GID, you need to pass these
|
||||
on the container start command line.
|
||||
|
||||
- If you want to access the RC interface (either via the API or the Web UI), it
|
||||
is required to set the `--rc-addr` to `:5572` in order to connect to it from outside
|
||||
- If you want to access the RC interface (either via the API or the Web UI), it is
|
||||
required to set the `--rc-addr` to `:5572` in order to connect to it from outside
|
||||
the container. An explanation about why this is necessary can be found in an old
|
||||
[pythonspeed.com](https://web.archive.org/web/20200808071950/https://pythonspeed.com/articles/docker-connection-refused/)
|
||||
article.
|
||||
@@ -309,9 +309,9 @@ container from the rclone image.
|
||||
probably set it to listen to localhost only, with `127.0.0.1:5572` as the
|
||||
value for `--rc-addr`
|
||||
|
||||
- It is possible to use `rclone mount` inside a userspace Docker container, and
|
||||
expose the resulting fuse mount to the host. The exact `docker run` options to
|
||||
do that might vary slightly between hosts. See, e.g. the discussion in this
|
||||
- It is possible to use `rclone mount` inside a userspace Docker container, and expose
|
||||
the resulting fuse mount to the host. The exact `docker run` options to do that
|
||||
might vary slightly between hosts. See, e.g. the discussion in this
|
||||
[thread](https://github.com/moby/moby/issues/9448).
|
||||
|
||||
You also need to mount the host `/etc/passwd` and `/etc/group` for fuse to work
|
||||
@@ -542,8 +542,8 @@ To override them set the corresponding options (as command-line arguments, or as
|
||||
|
||||
After installing and configuring rclone, as described above, you are ready to use
|
||||
rclone as an interactive command line utility. If your goal is to perform *periodic*
|
||||
operations, such as a regular [sync](https://rclone.org/commands/rclone_sync/),
|
||||
you will probably want to configure your rclone command in your operating system's
|
||||
operations, such as a regular [sync](https://rclone.org/commands/rclone_sync/), you
|
||||
will probably want to configure your rclone command in your operating system's
|
||||
scheduler. If you need to expose *service*-like features, such as
|
||||
[remote control](https://rclone.org/rc/), [GUI](https://rclone.org/gui/),
|
||||
[serve](https://rclone.org/commands/rclone_serve/) or [mount](https://rclone.org/commands/rclone_mount/),
|
||||
@@ -583,9 +583,9 @@ c:\rclone\rclone.exe sync c:\files remote:/files --no-console --log-file c:\rclo
|
||||
|
||||
As mentioned in the [mount](https://rclone.org/commands/rclone_mount/) documentation,
|
||||
mounted drives created as Administrator are not visible to other accounts, not even
|
||||
the account that was elevated as Administrator. By running the mount command as
|
||||
the built-in `SYSTEM` user account, it will create drives accessible for everyone
|
||||
on the system. Both scheduled task and Windows service can be used to achieve this.
|
||||
the account that was elevated as Administrator. By running the mount command as the
|
||||
built-in `SYSTEM` user account, it will create drives accessible for everyone on
|
||||
the system. Both scheduled task and Windows service can be used to achieve this.
|
||||
|
||||
NOTE: Remember that when rclone runs as the `SYSTEM` user, the user profile
|
||||
that it sees will not be yours. This means that if you normally run rclone with
|
||||
@@ -615,8 +615,8 @@ will often give you better results.
|
||||
|
||||
#### Start from Task Scheduler
|
||||
|
||||
Task Scheduler is an administrative tool built into Windows, and it can be used
|
||||
to configure rclone to be started automatically in a highly configurable way, e.g.
|
||||
Task Scheduler is an administrative tool built into Windows, and it can be used to
|
||||
configure rclone to be started automatically in a highly configurable way, e.g.
|
||||
periodically on a schedule, on user log on, or at system startup. It can run
|
||||
be configured to run as the current user, or for a mount command that needs to
|
||||
be available to all users it can run as the `SYSTEM` user.
|
||||
@@ -656,18 +656,18 @@ To Windows service running any rclone command, the excellent third-party utility
|
||||
[NSSM](http://nssm.cc), the "Non-Sucking Service Manager", can be used.
|
||||
It includes some advanced features such as adjusting process priority, defining
|
||||
process environment variables, redirect to file anything written to stdout, and
|
||||
customized response to different exit codes, with a GUI to configure everything
|
||||
from (although it can also be used from command line ).
|
||||
customized response to different exit codes, with a GUI to configure everything from
|
||||
(although it can also be used from command line ).
|
||||
|
||||
There are also several other alternatives. To mention one more,
|
||||
[WinSW](https://github.com/winsw/winsw), "Windows Service Wrapper", is worth checking
|
||||
out. It requires .NET Framework, but it is preinstalled on newer versions of Windows,
|
||||
and it also provides alternative standalone distributions which includes necessary
|
||||
runtime (.NET 5). WinSW is a command-line only utility, where you have to manually
|
||||
create an XML file with service configuration. This may be a drawback for some,
|
||||
but it can also be an advantage as it is easy to back up and reuse the configuration
|
||||
settings, without having go through manual steps in a GUI. One thing to note is
|
||||
that by default it does not restart the service on error, one have to explicit enable
|
||||
create an XML file with service configuration. This may be a drawback for some, but
|
||||
it can also be an advantage as it is easy to back up and reuse the configuration
|
||||
settings, without having go through manual steps in a GUI. One thing to note is that
|
||||
by default it does not restart the service on error, one have to explicit enable
|
||||
this in the configuration file (via the "onfailure" parameter).
|
||||
|
||||
### Autostart on Linux
|
||||
@@ -676,8 +676,8 @@ this in the configuration file (via the "onfailure" parameter).
|
||||
|
||||
To always run rclone in background, relevant for mount commands etc,
|
||||
you can use systemd to set up rclone as a system or user service. Running as a
|
||||
system service ensures that it is run at startup even if the user it is running
|
||||
as has no active session. Running rclone as a user service ensures that it only
|
||||
system service ensures that it is run at startup even if the user it is running as
|
||||
has no active session. Running rclone as a user service ensures that it only
|
||||
starts after the configured user has logged into the system.
|
||||
|
||||
#### Run periodically from cron
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Internet Archive"
|
||||
versionIntroduced: "v1.59"
|
||||
---
|
||||
|
||||
# Internet Archive
|
||||
# {{< icon "fa fa-archive" >}} Internet Archive
|
||||
|
||||
The Internet Archive backend utilizes Items on [archive.org](https://archive.org/)
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Internxt Drive"
|
||||
versionIntroduced: "v1.73"
|
||||
---
|
||||
|
||||
# Internxt Drive
|
||||
# {{< icon "fas fa-cloud" >}} Internxt Drive
|
||||
|
||||
[Internxt Drive](https://internxt.com) is a zero-knowledge encrypted cloud storage service.
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Jottacloud"
|
||||
versionIntroduced: "v1.43"
|
||||
---
|
||||
|
||||
# Jottacloud
|
||||
# {{< icon "fa fa-cloud" >}} Jottacloud
|
||||
|
||||
Jottacloud is a cloud storage service provider from a Norwegian company, using
|
||||
its own datacenters in Norway.
|
||||
@@ -12,7 +12,7 @@ its own datacenters in Norway.
|
||||
In addition to the official service at [jottacloud.com](https://www.jottacloud.com/),
|
||||
it also provides white-label solutions to different companies. The following
|
||||
are currently supported by this backend, using a different authentication setup
|
||||
as described [below](#traditional):
|
||||
as described [below](#whitelabel-authentication):
|
||||
|
||||
- Elkjøp (with subsidiaries):
|
||||
- Elkjøp Cloud (cloud.elkjop.no)
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Koofr"
|
||||
versionIntroduced: "v1.47"
|
||||
---
|
||||
|
||||
# Koofr
|
||||
# {{< icon "fa fa-suitcase" >}} Koofr
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Linkbox"
|
||||
versionIntroduced: "v1.65"
|
||||
---
|
||||
|
||||
# Linkbox
|
||||
# {{< icon "fa fa-infinity" >}} Linkbox
|
||||
|
||||
Linkbox is [a private cloud drive](https://linkbox.to/).
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for the local filesystem"
|
||||
versionIntroduced: "v0.91"
|
||||
---
|
||||
|
||||
# Local Filesystem
|
||||
# {{< icon "fas fa-hdd" >}} Local Filesystem
|
||||
|
||||
Local paths are specified as normal filesystem paths, e.g. `/path/to/wherever`, so
|
||||
|
||||
@@ -62,7 +62,7 @@ handling file names.
|
||||
| / | 0x2F | / |
|
||||
|
||||
When running on Windows the following characters are replaced. This
|
||||
list is based on the [Windows file naming conventions](https://docs.microsoft.com/windows/desktop/FileIO/naming-a-file#naming-conventions).
|
||||
list is based on the [Windows file naming conventions](https://docs.microsoft.com/de-de/windows/desktop/FileIO/naming-a-file#naming-conventions).
|
||||
|
||||
| Character | Value | Replacement |
|
||||
| --------- |:-----:|:-----------:|
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Mail.ru Cloud"
|
||||
versionIntroduced: "v1.50"
|
||||
---
|
||||
|
||||
# Mail.ru Cloud
|
||||
# {{< icon "fas fa-at" >}} Mail.ru Cloud
|
||||
|
||||
[Mail.ru Cloud](https://cloud.mail.ru/) is a cloud storage provided by a
|
||||
Russian internet company [Mail.Ru Group](https://mail.ru). The official
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Mega"
|
||||
versionIntroduced: "v1.41"
|
||||
---
|
||||
|
||||
# Mega
|
||||
# {{< icon "fa fa-archive" >}} Mega
|
||||
|
||||
[Mega](https://mega.nz/) is a cloud storage and file hosting service
|
||||
known for its security feature where all files are encrypted locally
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Memory backend"
|
||||
versionIntroduced: "v1.51"
|
||||
---
|
||||
|
||||
# Memory
|
||||
# {{< icon "fas fa-memory" >}} Memory
|
||||
|
||||
The memory backend is an in RAM backend. It does not persist its
|
||||
data - use the local backend for that.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Akamai NetStorage"
|
||||
versionIntroduced: "v1.58"
|
||||
---
|
||||
|
||||
# Akamai NetStorage
|
||||
# {{< icon "fas fa-database" >}} Akamai NetStorage
|
||||
|
||||
Paths are specified as `remote:`
|
||||
You may put subdirectories in too, e.g. `remote:/path/to/dir`.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Microsoft OneDrive"
|
||||
versionIntroduced: "v1.24"
|
||||
---
|
||||
|
||||
# Microsoft OneDrive
|
||||
# {{< icon "fab fa-windows" >}} Microsoft OneDrive
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for OpenDrive"
|
||||
versionIntroduced: "v1.42"
|
||||
---
|
||||
|
||||
# OpenDrive
|
||||
# {{< icon "fa fa-file" >}} OpenDrive
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ type: page
|
||||
versionIntroduced: "v1.60"
|
||||
---
|
||||
|
||||
# Oracle Object Storage
|
||||
# {{< icon "fa fa-cloud" >}} Oracle Object Storage
|
||||
|
||||
Object Storage provided by the Oracle Cloud Infrastructure (OCI).
|
||||
Read more at <oracle.com>:
|
||||
|
||||
@@ -3,7 +3,7 @@ title: "Oracle Object Storage Mount"
|
||||
description: "Oracle Object Storage mounting tutorial"
|
||||
---
|
||||
|
||||
# Mount Buckets and Expose via NFS Tutorial
|
||||
# {{< icon "fa fa-cloud" >}} Mount Buckets and Expose via NFS Tutorial
|
||||
|
||||
This runbook shows how to [mount](/commands/rclone_mount/) *Oracle Object Storage*
|
||||
buckets as local file system in OCI compute Instance using rclone tool.
|
||||
|
||||
+12
-12
@@ -39,7 +39,7 @@ size by default, though can be configured to check the file hash
|
||||
change the timestamp of an existing file without having to re-upload it.
|
||||
|
||||
| Key | Explanation |
|
||||
| --- | ----------- |
|
||||
|-----|-------------|
|
||||
| `-` | ModTimes not supported - times likely the upload time |
|
||||
| `R` | ModTimes supported on files but can't be changed without re-upload |
|
||||
| `R/W` | Read and Write ModTimes fully supported on files |
|
||||
@@ -186,8 +186,8 @@ will be escaped with the `‛` character to avoid ambiguous file names.
|
||||
Each cloud storage backend can use a different set of characters,
|
||||
which will be specified in the documentation for each backend.
|
||||
|
||||
| Character | Value | Replacement |
|
||||
| --------- | :---: | :---------- :|
|
||||
| Character | Value | Replacement |
|
||||
| --------- |:-----:|:-----------:|
|
||||
| NUL | 0x00 | ␀ |
|
||||
| SOH | 0x01 | ␁ |
|
||||
| STX | 0x02 | ␂ |
|
||||
@@ -227,9 +227,9 @@ The default encoding will also encode these file names as they are
|
||||
problematic with many cloud storage systems.
|
||||
|
||||
| File name | Replacement |
|
||||
| --------- | :--------- :|
|
||||
| --------- |:-----------:|
|
||||
| . | . |
|
||||
| .. | .. |
|
||||
| .. | .. |
|
||||
|
||||
#### Invalid UTF-8 bytes {#invalid-utf8}
|
||||
|
||||
@@ -269,8 +269,8 @@ list of all possible values by passing an invalid value to this
|
||||
flag, e.g. `--local-encoding "help"`. The command `rclone help flags encoding`
|
||||
will show you the defaults for the backends.
|
||||
|
||||
| Encoding | Characters | Encoded as |
|
||||
| -------- | ---------- | ---------- |
|
||||
| Encoding | Characters | Encoded as |
|
||||
| --------- | ---------- | ---------- |
|
||||
| Asterisk | `*` | `*` |
|
||||
| BackQuote | `` ` `` | ``` |
|
||||
| BackSlash | `\` | `\` |
|
||||
@@ -395,12 +395,12 @@ that backend) and/or user metadata (general purpose metadata).
|
||||
The levels of metadata support are
|
||||
|
||||
| Key | Explanation |
|
||||
| --- | ----------- |
|
||||
| `R` | Read only System Metadata on files only |
|
||||
| `RW` | Read and write System Metadata on files only |
|
||||
| `RWU` | Read and write System Metadata and read and write User Metadata on files only |
|
||||
|-----|-------------|
|
||||
| `R` | Read only System Metadata on files only|
|
||||
| `RW` | Read and write System Metadata on files only|
|
||||
| `RWU` | Read and write System Metadata and read and write User Metadata on files only|
|
||||
| `DR` | Read only System Metadata on files and directories |
|
||||
| `DRW` | Read and write System Metadata on files and directories |
|
||||
| `DRW` | Read and write System Metadata on files and directories|
|
||||
| `DRWU` | Read and write System Metadata and read and write User Metadata on files and directories |
|
||||
|
||||
See [the metadata docs](/docs/#metadata) for more info.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for pCloud"
|
||||
versionIntroduced: "v1.39"
|
||||
---
|
||||
|
||||
# pCloud
|
||||
# {{< icon "fa fa-cloud" >}} pCloud
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for PikPak"
|
||||
versionIntroduced: "v1.62"
|
||||
---
|
||||
|
||||
# PikPak
|
||||
# {{< icon "fa fa-cloud" >}} PikPak
|
||||
|
||||
PikPak is [a private cloud drive](https://mypikpak.com/).
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Pixeldrain"
|
||||
versionIntroduced: "v1.68"
|
||||
---
|
||||
|
||||
# Pixeldrain
|
||||
# {{< icon "fa fa-circle" >}} Pixeldrain
|
||||
|
||||
This is the backend for Pixeldrain's premium filesystem feature. This is not the
|
||||
same as pixeldrain's free file sharing product. The filesystem requires either a
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for premiumize.me"
|
||||
versionIntroduced: "v1.49"
|
||||
---
|
||||
|
||||
# premiumize.me
|
||||
# {{< icon "fa fa-user" >}} premiumize.me
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Proton Drive"
|
||||
versionIntroduced: "v1.64.0"
|
||||
---
|
||||
|
||||
# Proton Drive
|
||||
# {{< icon "fa fa-folder" >}} Proton Drive
|
||||
|
||||
[Proton Drive](https://proton.me/drive) is an end-to-end encrypted Swiss vault
|
||||
for your files that protects your data.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for put.io"
|
||||
versionIntroduced: "v1.49"
|
||||
---
|
||||
|
||||
# put.io
|
||||
# {{< icon "fas fa-parking" >}} put.io
|
||||
|
||||
Paths are specified as `remote:path`
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for QingStor Object Storage"
|
||||
versionIntroduced: "v1.38"
|
||||
---
|
||||
|
||||
# QingStor
|
||||
# {{< icon "fas fa-hdd" >}} QingStor
|
||||
|
||||
Paths are specified as `remote:bucket` (or `remote:` for the `lsd`
|
||||
command.) You may put subdirectories in too, e.g. `remote:bucket/path/to/dir`.
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Quatrix"
|
||||
versionIntroduced: "v1.63.2"
|
||||
---
|
||||
|
||||
# Quatrix
|
||||
# {{< icon "fas fa-shield-alt" >}} Quatrix
|
||||
|
||||
Quatrix by Maytech is [Quatrix Secure Compliant File Sharing | Maytech](https://www.maytech.net/products/quatrix-business).
|
||||
|
||||
|
||||
+7
-145
@@ -4,7 +4,7 @@ description: "Rclone docs for Amazon S3"
|
||||
versionIntroduced: "v0.91"
|
||||
---
|
||||
|
||||
# Amazon S3 Storage Providers
|
||||
# {{< icon "fab fa-amazon" >}} Amazon S3 Storage Providers
|
||||
|
||||
The S3 backend can be used with a number of different providers:
|
||||
|
||||
@@ -55,7 +55,6 @@ The S3 backend can be used with a number of different providers:
|
||||
{{< provider name="Storj" home="https://storj.io/" config="/s3/#storj" >}}
|
||||
{{< provider name="Synology C2 Object Storage" home="https://c2.synology.com/en-global/object-storage/overview" config="/s3/#synology-c2" >}}
|
||||
{{< provider name="Tencent Cloud Object Storage (COS)" home="https://intl.cloud.tencent.com/product/cos" config="/s3/#tencent-cos" >}}
|
||||
{{< provider name="US3" home="https://www.ucloud.cn/site/product/ufile.html" config="/s3/#us3" >}}
|
||||
{{< provider name="Wasabi" home="https://wasabi.com/" config="/s3/#wasabi" >}}
|
||||
{{< provider name="Zadara Object Storage" home="https://www.zadara.com" config="/s3/#zadara" >}}
|
||||
{{< provider name="Zata" home="https://zata.ai/" config="/s3/#Zata" end="true" >}}
|
||||
@@ -914,9 +913,10 @@ According to AWS's [documentation on S3 Object Lock](https://docs.aws.amazon.com
|
||||
> If you configure a default retention period on a bucket, requests to upload
|
||||
objects in such a bucket must include the Content-MD5 header.
|
||||
|
||||
Rclone automatically computes and includes the Content-MD5 header when
|
||||
uploading objects with Object Lock parameters set. No special
|
||||
configuration is needed.
|
||||
As mentioned in the [Modification times and hashes](#modification-times-and-hashes)
|
||||
section, small files that are not uploaded as multipart, use a different tag, causing
|
||||
the upload to fail. A simple solution is to set the `--s3-upload-cutoff 0` and force
|
||||
all the files to be uploaded as multipart.
|
||||
|
||||
#### Setting Object Lock retention
|
||||
|
||||
@@ -5132,9 +5132,7 @@ can follow this [guide](https://docs.cubbit.io/getting-started/quickstart#api-ke
|
||||
to retrieve these keys. They will be needed when prompted by `rclone config`.
|
||||
|
||||
Default region will correspond to `eu-west-1` and the endpoint has to be specified
|
||||
as `s3.cubbit.eu`. If you set a custom tenant endpoint, you must use
|
||||
`s3.{tenant_name}.cubbit.eu`, because the generic `s3.cubbit.eu` endpoint will not
|
||||
work in this case.
|
||||
as `s3.cubbit.eu`.
|
||||
|
||||
Going through the whole process of creating a new remote by running `rclone config`,
|
||||
each prompt should be answered as shown below:
|
||||
@@ -5147,7 +5145,7 @@ env_auth> false
|
||||
access_key_id> YOUR_ACCESS_KEY
|
||||
secret_access_key> YOUR_SECRET_KEY
|
||||
region> eu-west-1 (or leave empty)
|
||||
endpoint> s3.cubbit.eu (or s3.{tenant_name}.cubbit.eu)
|
||||
endpoint> s3.cubbit.eu
|
||||
acl>
|
||||
```
|
||||
|
||||
@@ -9119,142 +9117,6 @@ To configure access to Tencent COS, follow the steps below:
|
||||
==== ====
|
||||
cos s3
|
||||
```
|
||||
### US3 {#us3}
|
||||
[US3](https://www.ucloud.cn/site/product/ufile.html) Object Storage is a service that provides cloud storage for unstructured files for internet applications.
|
||||
|
||||
To configure access to US3, follow the steps below:
|
||||
1. First run:
|
||||
```console
|
||||
rclone config
|
||||
No remotes found, make a new one?
|
||||
n) New remote
|
||||
s) Set configuration password
|
||||
q) Quit config
|
||||
n/s/q> n
|
||||
```
|
||||
2. Give the name of the configuration. For example, name it 'US3'.
|
||||
|
||||
```text
|
||||
name> US3
|
||||
```
|
||||
3. Select `s3` storage.
|
||||
|
||||
```text
|
||||
Choose a number from below, or type in your own value
|
||||
[snip]
|
||||
XX / Amazon S3 Compliant Storage Providers including AWS, ...
|
||||
\ "s3"
|
||||
[snip]
|
||||
Storage> s3
|
||||
```
|
||||
4. Select `US3` provider.
|
||||
|
||||
```text
|
||||
Choose a number from below, or type in your own value.
|
||||
XX / Amazon Web Services (AWS) S3
|
||||
\ (AWS)
|
||||
[snip]
|
||||
XX / UCloud Object Storage (US3)
|
||||
\ (US3)
|
||||
[snip]
|
||||
provider> US3
|
||||
```
|
||||
5. Enter your SecretId and SecretKey of US3.
|
||||
|
||||
```text
|
||||
Get AWS credentials from runtime (environment variables or EC2/ECS meta data if no env vars).
|
||||
Only applies if access_key_id and secret_access_key is blank.
|
||||
Choose a number from below, or type in your own boolean value (true or false).
|
||||
Press Enter for the default (false).
|
||||
Choose a number from below, or type in your own value
|
||||
1 / Enter AWS credentials in the next step
|
||||
\ "false"
|
||||
2 / Get AWS credentials from the environment (env vars or IAM)
|
||||
\ "true"
|
||||
env_auth> 1
|
||||
Option access_key_id.
|
||||
AWS Access Key ID.
|
||||
Leave blank for anonymous access or runtime credentials.
|
||||
Enter a value. Press Enter to leave empty.
|
||||
access_key_id> AKIDxxxxxxxxxx
|
||||
AWS Secret Access Key (password)
|
||||
Leave blank for anonymous access or runtime credentials.
|
||||
Enter a string value. Press Enter for the default ("").
|
||||
secret_access_key> xxxxxxxxxxx
|
||||
```
|
||||
|
||||
6. Select endpoint.
|
||||
```text
|
||||
Option endpoint.
|
||||
Endpoint for S3 API.
|
||||
Required when using an S3 clone.
|
||||
Choose a number from below, or type in your own value.
|
||||
Press Enter to leave empty.
|
||||
1 / North China (Beijing 2).
|
||||
\ "s3-cn-bj.ufileos.com"
|
||||
2 / North China (Ulanqab).
|
||||
\ "s3-cn-wlcb.ufileos.com"
|
||||
3 / Shanghai.
|
||||
\ "s3-cn-sh2.ufileos.com"
|
||||
4 / South China (Guangzhou).
|
||||
\ "s3-cn-gd.ufileos.com"
|
||||
[snip]
|
||||
endpoint> 1
|
||||
```
|
||||
|
||||
7. Choose acl and storage class.
|
||||
|
||||
```text
|
||||
Option acl.
|
||||
Canned ACL used when creating buckets and storing or copying objects.
|
||||
This ACL is used for creating objects and if bucket_acl isn't set, for creating buckets too.
|
||||
For more info visit https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
|
||||
Note that this ACL is applied when server-side copying objects as S3
|
||||
doesn't copy the ACL from the source but rather writes a fresh one.
|
||||
If the acl is an empty string then no X-Amz-Acl: header is added and
|
||||
the default (private) will be used.
|
||||
Choose a number from below, or type in your own value.
|
||||
Press Enter to leave empty.
|
||||
/ Owner gets FULL_CONTROL.
|
||||
1 | No one else has access rights (default).
|
||||
\ (private)
|
||||
/ Owner gets FULL_CONTROL.
|
||||
2 | The AllUsers group gets READ access.
|
||||
\ (public-read)
|
||||
acl> 1
|
||||
|
||||
The storage class to use when storing new objects in US3.
|
||||
Enter a string value. Press Enter for the default ("").
|
||||
Choose a number from below, or type in your own value
|
||||
1 / Default
|
||||
\ ""
|
||||
[snip]
|
||||
storage_class> 1
|
||||
Edit advanced config? (y/n)
|
||||
y) Yes
|
||||
n) No (default)
|
||||
y/n> n
|
||||
|
||||
Configuration complete.
|
||||
Options:
|
||||
- type: s3
|
||||
- provider: US3
|
||||
- access_key_id: xx
|
||||
- secret_access_key: xx
|
||||
- endpoint: s3-cn-bj.ufileos.com
|
||||
- acl: private
|
||||
|
||||
Keep this "US3" remote?
|
||||
y) Yes this is OK (default)
|
||||
e) Edit this remote
|
||||
d) Delete this remote
|
||||
y/e/d> y
|
||||
Current remotes:
|
||||
|
||||
Name Type
|
||||
==== ====
|
||||
US3 s3
|
||||
```
|
||||
|
||||
### Wasabi
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Seafile"
|
||||
versionIntroduced: "v1.52"
|
||||
---
|
||||
|
||||
# Seafile
|
||||
# {{< icon "fa fa-server" >}} Seafile
|
||||
|
||||
This is a backend for the [Seafile](https://www.seafile.com/) storage service:
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "SFTP"
|
||||
versionIntroduced: "v1.36"
|
||||
---
|
||||
|
||||
# SFTP
|
||||
# {{< icon "fa fa-server" >}} SFTP
|
||||
|
||||
SFTP is the [Secure (or SSH) File Transfer
|
||||
Protocol](https://en.wikipedia.org/wiki/SSH_File_Transfer_Protocol).
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Shade Backend Docs"
|
||||
versionIntroduced: "v1.73"
|
||||
---
|
||||
|
||||
# Shade
|
||||
# {{< icon "fa fa-moon" >}} Shade
|
||||
|
||||
This is a backend for the [Shade](https://shade.inc/) platform
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ description: "Rclone docs for Citrix ShareFile"
|
||||
versionIntroduced: "v1.50"
|
||||
---
|
||||
|
||||
# Citrix ShareFile
|
||||
# {{< icon "fas fa-share-square" >}} Citrix ShareFile
|
||||
|
||||
[Citrix ShareFile](https://sharefile.com) is a secure file sharing and transfer
|
||||
service aimed as business.
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ versionIntroduced: "v1.57"
|
||||
date: "2019-10-02"
|
||||
---
|
||||
|
||||
# Sia
|
||||
# {{< icon "fa fa-globe" >}} Sia
|
||||
|
||||
Sia ([sia.tech](https://sia.tech/)) is a decentralized cloud storage platform
|
||||
based on the [blockchain](https://wikipedia.org/wiki/Blockchain) technology.
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ description: "Rclone docs for SMB backend"
|
||||
versionIntroduced: "v1.60"
|
||||
---
|
||||
|
||||
# SMB
|
||||
# {{< icon "fa fa-server" >}} SMB
|
||||
|
||||
SMB is [a communication protocol to share files over network](https://en.wikipedia.org/wiki/Server_Message_Block).
|
||||
|
||||
|
||||
@@ -6,13 +6,14 @@ aliases:
|
||||
- donate
|
||||
---
|
||||
|
||||
# Sponsor the rclone project
|
||||
# {{< icon "fa fa-heart heart" >}} Sponsor the rclone project
|
||||
|
||||
Thank you to our sponsors:
|
||||
|
||||
<!-- markdownlint-capture -->
|
||||
<!-- markdownlint-disable line-length no-bare-urls -->
|
||||
|
||||
{{< sponsor src="/img/logos/rabata.svg" width="300" height="200" title="Visit our sponsor Rabata.io" link="https://rabata.io/?utm_source=banner&utm_medium=rclone&utm_content=general">}}
|
||||
{{< sponsor src="/img/logos/idrive_e2.svg" width="300" height="200" title="Visit our sponsor IDrive e2" link="https://www.idrive.com/e2/?refer=rclone">}}
|
||||
{{< sponsor src="/img/logos/filescom-enterprise-grade-workflows.png" width="300" height="200" title="Start Your Free Trial Today" link="https://files.com/?utm_source=rclone&utm_medium=referral&utm_campaign=banner&utm_term=rclone">}}
|
||||
{{< sponsor src="/img/logos/internxt.jpg" width="300" height="200" title="Visit rclone's sponsor Internxt" link="https://internxt.com/specialoffer/rclone">}}
|
||||
@@ -65,7 +66,7 @@ details.
|
||||
|
||||
If you are a personal user and you would like to support the project
|
||||
with sponsorship as a way of saying thank you that would be most
|
||||
appreciated.
|
||||
appreciated. {{< icon "fa fa-heart heart" >}}
|
||||
|
||||
{{< monthly_donations >}}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ aliases:
|
||||
versionIntroduced: "v1.52"
|
||||
---
|
||||
|
||||
# Storj
|
||||
# {{< icon "fas fa-dove" >}} Storj
|
||||
|
||||
[Storj](https://storj.io) is redefining the cloud to support the
|
||||
future of data—sustainably and economically. Storj leverages the vast
|
||||
|
||||
Loaded 100 of 155 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user