Compare commits
18
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb17dd9fe7 | ||
|
|
14b56fa7dc | ||
|
|
5d6690eb20 | ||
|
|
c7b8654b17 | ||
|
|
906b27d8b9 | ||
|
|
e233f8b0a7 | ||
|
|
17a547a980 | ||
|
|
cdb3ecb0fb | ||
|
|
2d7f84576a | ||
|
|
ab234dcfd7 | ||
|
|
c5bcfbac8f | ||
|
|
88ed8e2b43 | ||
|
|
b097454f83 | ||
|
|
2f890114b6 | ||
|
|
78a7d9bb8e | ||
|
|
72c561d209 | ||
|
|
b864c4f9c9 | ||
|
|
bb78eb8ab2 |
No files matched your search
@@ -100,7 +100,7 @@ jobs:
|
||||
|
||||
- name: Extract Metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
env:
|
||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: manifest,manifest-descriptor # Important for digest annotation (used by Github packages)
|
||||
with:
|
||||
@@ -122,10 +122,10 @@ jobs:
|
||||
type=raw,value=beta,enable={{is_default_branch}}
|
||||
|
||||
- name: Setup QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
uses: docker/setup-qemu-action@v4
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Load Go Build Cache for Docker
|
||||
id: go-cache
|
||||
@@ -148,7 +148,7 @@ jobs:
|
||||
skip-extraction: ${{ steps.go-cache.outputs.cache-hit }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
# This is the user that triggered the Workflow. In this case, it will
|
||||
@@ -159,7 +159,7 @@ jobs:
|
||||
|
||||
- name: Build and Publish Image Digest
|
||||
id: build
|
||||
uses: docker/build-push-action@v6
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
file: Dockerfile
|
||||
context: .
|
||||
@@ -210,7 +210,7 @@ jobs:
|
||||
|
||||
- name: Extract Metadata (tags, labels) for Docker
|
||||
id: meta
|
||||
uses: docker/metadata-action@v5
|
||||
uses: docker/metadata-action@v6
|
||||
env:
|
||||
DOCKER_METADATA_ANNOTATIONS_LEVELS: index
|
||||
with:
|
||||
@@ -261,16 +261,16 @@ jobs:
|
||||
env.write(f"ANNOTATIONS={annotations_string}\n")
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
uses: docker/setup-buildx-action@v4
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GitHub Container Registry
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ghcr.io
|
||||
# This is the user that triggered the Workflow. In this case, it will
|
||||
|
||||
@@ -146,6 +146,7 @@ MANUAL.txt: MANUAL.md
|
||||
|
||||
commanddocs: rclone
|
||||
go generate ./lib/transform
|
||||
go generate ./cmd/bisync
|
||||
-@rmdir -p '$$HOME/.config/rclone'
|
||||
XDG_CACHE_HOME="" XDG_CONFIG_HOME="" HOME="\$$HOME" USER="\$$USER" rclone gendocs --config=/notfound docs/content/
|
||||
@[ ! -e '$$HOME' ] || (echo 'Error: created unwanted directory named $$HOME' && exit 1)
|
||||
|
||||
+2
-1
@@ -32,10 +32,11 @@ This file describes how to make the various kinds of releases
|
||||
- make sign_upload
|
||||
- make check_sign
|
||||
- make upload
|
||||
- make upload_test_website # check sponsors are correct/unchanged
|
||||
- make upload_website
|
||||
- make upload_github
|
||||
- make startdev # make startstable for stable branch
|
||||
- \# announce with forum post, twitter post, patreon post
|
||||
- \# announce with forum post, twitter post, and post to annoucements list
|
||||
|
||||
## Update dependencies
|
||||
|
||||
|
||||
+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)
|
||||
+4
-3
@@ -127,14 +127,14 @@ func init() {
|
||||
// and the Command line syntax section of docs/content/bisync.md (it doesn't update automatically)
|
||||
flags.BoolVarP(cmdFlags, &Opt.Resync, "resync", "1", Opt.Resync, "Performs the resync run. Equivalent to --resync-mode path1. Consider using --verbose or --dry-run first.", "")
|
||||
flags.FVarP(cmdFlags, &Opt.ResyncMode, "resync-mode", "", "During resync, prefer the version that is: path1, path2, newer, older, larger, smaller (default: path1 if --resync, otherwise none for no resync.)", "")
|
||||
flags.BoolVarP(cmdFlags, &Opt.CheckAccess, "check-access", "", Opt.CheckAccess, makeHelp("Ensure expected {CHECKFILE} files are found on both Path1 and Path2 filesystems, else abort."), "")
|
||||
flags.StringVarP(cmdFlags, &Opt.CheckFilename, "check-filename", "", Opt.CheckFilename, makeHelp("Filename for --check-access (default: {CHECKFILE})"), "")
|
||||
flags.BoolVarP(cmdFlags, &Opt.CheckAccess, "check-access", "", Opt.CheckAccess, MakeHelp("Ensure expected {CHECKFILE} files are found on both Path1 and Path2 filesystems, else abort."), "")
|
||||
flags.StringVarP(cmdFlags, &Opt.CheckFilename, "check-filename", "", Opt.CheckFilename, MakeHelp("Filename for --check-access (default: {CHECKFILE})"), "")
|
||||
flags.BoolVarP(cmdFlags, &Opt.Force, "force", "", Opt.Force, "Bypass --max-delete safety check and run the sync. Consider using with --verbose", "")
|
||||
flags.FVarP(cmdFlags, &Opt.CheckSync, "check-sync", "", "Controls comparison of final listings: true|false|only (default: true)", "")
|
||||
flags.BoolVarP(cmdFlags, &Opt.CreateEmptySrcDirs, "create-empty-src-dirs", "", Opt.CreateEmptySrcDirs, "Sync creation and deletion of empty directories. (Not compatible with --remove-empty-dirs)", "")
|
||||
flags.BoolVarP(cmdFlags, &Opt.RemoveEmptyDirs, "remove-empty-dirs", "", Opt.RemoveEmptyDirs, "Remove ALL empty directories at the final cleanup step.", "")
|
||||
flags.StringVarP(cmdFlags, &Opt.FiltersFile, "filters-file", "", Opt.FiltersFile, "Read filtering patterns from a file", "")
|
||||
flags.StringVarP(cmdFlags, &Opt.Workdir, "workdir", "", Opt.Workdir, makeHelp("Use custom working dir - useful for testing. (default: {WORKDIR})"), "")
|
||||
flags.StringVarP(cmdFlags, &Opt.Workdir, "workdir", "", Opt.Workdir, MakeHelp("Use custom working dir - useful for testing. (default: {WORKDIR})"), "")
|
||||
flags.StringVarP(cmdFlags, &Opt.BackupDir1, "backup-dir1", "", Opt.BackupDir1, "--backup-dir for Path1. Must be a non-overlapping path on the same remote.", "")
|
||||
flags.StringVarP(cmdFlags, &Opt.BackupDir2, "backup-dir2", "", Opt.BackupDir2, "--backup-dir for Path2. Must be a non-overlapping path on the same remote.", "")
|
||||
flags.StringVarP(cmdFlags, &Opt.DebugName, "debugname", "", Opt.DebugName, "Debug by tracking one file at various points throughout a bisync run (when -v or -vv)", "")
|
||||
@@ -153,6 +153,7 @@ func init() {
|
||||
flags.StringVarP(cmdFlags, &Opt.ConflictSuffixFlag, "conflict-suffix", "", Opt.ConflictSuffixFlag, "Suffix to use when renaming a --conflict-loser. Can be either one string or two comma-separated strings to assign different suffixes to Path1/Path2. (default: 'conflict')", "")
|
||||
_ = cmdFlags.MarkHidden("debugname")
|
||||
_ = cmdFlags.MarkHidden("localtime")
|
||||
addRC()
|
||||
}
|
||||
|
||||
// bisync command definition
|
||||
|
||||
+65
-53
@@ -1,65 +1,77 @@
|
||||
package bisync
|
||||
//go:build none
|
||||
|
||||
// Create the help text for the rc
|
||||
//
|
||||
// Run with go generate ./cmd/bisync (defined in rc.go)
|
||||
package main
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/muesli/reflow/wordwrap"
|
||||
"github.com/rclone/rclone/cmd"
|
||||
"github.com/rclone/rclone/cmd/bisync"
|
||||
"github.com/rclone/rclone/fs"
|
||||
"github.com/spf13/pflag"
|
||||
"golang.org/x/text/cases"
|
||||
"golang.org/x/text/language"
|
||||
)
|
||||
|
||||
func makeHelp(help string) string {
|
||||
replacer := strings.NewReplacer(
|
||||
"|", "`",
|
||||
"{MAXDELETE}", strconv.Itoa(DefaultMaxDelete),
|
||||
"{CHECKFILE}", DefaultCheckFilename,
|
||||
// "{WORKDIR}", DefaultWorkdir,
|
||||
)
|
||||
return replacer.Replace(help)
|
||||
// Output the help to stdout
|
||||
func main() {
|
||||
out := os.Stdout
|
||||
if len(os.Args) > 1 {
|
||||
var err error
|
||||
out, err = os.Create(os.Args[1])
|
||||
if err != nil {
|
||||
fs.Fatalf(nil, "Open output failed: %v", err)
|
||||
}
|
||||
defer out.Close()
|
||||
}
|
||||
fmt.Fprintf(out, "<!--- Docs generated by help.go - use go generate to rebuild - DO NOT EDIT --->\n\n")
|
||||
fmt.Fprint(out, RcHelp())
|
||||
}
|
||||
|
||||
var shortHelp = `Perform bidirectional synchronization between two paths.`
|
||||
|
||||
var rcHelp = makeHelp(`This takes the following parameters
|
||||
|
||||
- path1 - a remote directory string e.g. |drive:path1|
|
||||
- path2 - a remote directory string e.g. |drive:path2|
|
||||
- dryRun - dry-run mode
|
||||
- resync - performs the resync run
|
||||
- checkAccess - abort if {CHECKFILE} files are not found on both filesystems
|
||||
- checkFilename - file name for checkAccess (default: {CHECKFILE})
|
||||
- maxDelete - abort sync if percentage of deleted files is above
|
||||
this threshold (default: {MAXDELETE})
|
||||
- force - Bypass maxDelete safety check and run the sync
|
||||
- checkSync - |true| by default, |false| disables comparison of final listings,
|
||||
|only| will skip sync, only compare listings from the last run
|
||||
- createEmptySrcDirs - Sync creation and deletion of empty directories.
|
||||
(Not compatible with --remove-empty-dirs)
|
||||
- removeEmptyDirs - remove empty directories at the final cleanup step
|
||||
- filtersFile - read filtering patterns from a file
|
||||
- ignoreListingChecksum - Do not use checksums for listings
|
||||
- resilient - Allow future runs to retry after certain less-serious errors, instead of requiring resync.
|
||||
- workdir - server directory for history files (default: |~/.cache/rclone/bisync|)
|
||||
- backupdir1 - --backup-dir for Path1. Must be a non-overlapping path on the same remote.
|
||||
- backupdir2 - --backup-dir for Path2. Must be a non-overlapping path on the same remote.
|
||||
- noCleanup - retain working files
|
||||
// RcHelp returns the rc help
|
||||
func RcHelp() string {
|
||||
return wordwrap.String(bisync.MakeHelp(`This takes the following parameters:
|
||||
|
||||
- path1 (required) - (string) a remote directory string e.g. ||drive:path1||
|
||||
- path2 (required) - (string) a remote directory string e.g. ||drive:path2||
|
||||
- dryRun - (bool) dry-run mode
|
||||
`+GenerateParams()+`
|
||||
See [bisync command help](https://rclone.org/commands/rclone_bisync/)
|
||||
and [full bisync description](https://rclone.org/bisync/)
|
||||
for more information.`)
|
||||
for more information.
|
||||
`), 76)
|
||||
}
|
||||
|
||||
var longHelp = shortHelp + makeHelp(`
|
||||
// example: "create-empty-src-dirs" -> "createEmptySrcDirs"
|
||||
func toCamel(s string) string {
|
||||
split := strings.Split(s, "-")
|
||||
builder := strings.Builder{}
|
||||
for i, word := range split {
|
||||
if i == 0 { // first word always all lowercase
|
||||
builder.WriteString(strings.ToLower(word))
|
||||
continue
|
||||
}
|
||||
builder.WriteString(cases.Title(language.AmericanEnglish).String(word))
|
||||
}
|
||||
return builder.String()
|
||||
}
|
||||
|
||||
[Bisync](https://rclone.org/bisync/) provides a
|
||||
bidirectional cloud sync solution in rclone.
|
||||
It retains the Path1 and Path2 filesystem listings from the prior run.
|
||||
On each successive run it will:
|
||||
|
||||
- list files on Path1 and Path2, and check for changes on each side.
|
||||
Changes include |New|, |Newer|, |Older|, and |Deleted| files.
|
||||
- Propagate changes on Path1 to Path2, and vice-versa.
|
||||
|
||||
Bisync is considered an **advanced command**, so use with care.
|
||||
Make sure you have read and understood the entire [manual](https://rclone.org/bisync)
|
||||
(especially the [Limitations](https://rclone.org/bisync/#limitations) section)
|
||||
before using, or data loss can result. Questions can be asked in the
|
||||
[Rclone Forum](https://forum.rclone.org/).
|
||||
|
||||
See [full bisync description](https://rclone.org/bisync/) for details.`)
|
||||
// GenerateParams automatically generates the param list from commandDefinition.Flags
|
||||
func GenerateParams() string {
|
||||
builder := strings.Builder{}
|
||||
fn := func(flag *pflag.Flag) {
|
||||
if flag.Hidden {
|
||||
return
|
||||
}
|
||||
builder.WriteString(fmt.Sprintf("- %s - (%s) %s \n", toCamel(flag.Name), flag.Value.Type(), flag.Usage))
|
||||
}
|
||||
commandDefinition, _, _ := cmd.Root.Find([]string{"bisync"})
|
||||
commandDefinition.Flags().VisitAll(fn)
|
||||
return builder.String()
|
||||
}
|
||||
+124
-25
@@ -1,16 +1,22 @@
|
||||
//go:generate go run help.go rc.md
|
||||
package bisync
|
||||
|
||||
import (
|
||||
"context"
|
||||
_ "embed"
|
||||
"errors"
|
||||
"log"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/rclone/rclone/cmd/bisync/bilib"
|
||||
"github.com/rclone/rclone/fs"
|
||||
fslog "github.com/rclone/rclone/fs/log"
|
||||
"github.com/rclone/rclone/fs/rc"
|
||||
)
|
||||
|
||||
func init() {
|
||||
func addRC() {
|
||||
rc.Add(rc.Call{
|
||||
Path: "sync/bisync",
|
||||
AuthRequired: true,
|
||||
@@ -20,6 +26,42 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
//go:embed rc.md
|
||||
var rcHelp string
|
||||
|
||||
var shortHelp = `Perform bidirectional synchronization between two paths.`
|
||||
|
||||
var longHelp = shortHelp + MakeHelp(`
|
||||
|
||||
[Bisync](https://rclone.org/bisync/) provides a
|
||||
bidirectional cloud sync solution in rclone.
|
||||
It retains the Path1 and Path2 filesystem listings from the prior run.
|
||||
On each successive run it will:
|
||||
|
||||
- list files on Path1 and Path2, and check for changes on each side.
|
||||
Changes include ||New||, ||Newer||, ||Older||, and ||Deleted|| files.
|
||||
- Propagate changes on Path1 to Path2, and vice-versa.
|
||||
|
||||
Bisync is considered an **advanced command**, so use with care.
|
||||
Make sure you have read and understood the entire [manual](https://rclone.org/bisync)
|
||||
(especially the [Limitations](https://rclone.org/bisync/#limitations) section)
|
||||
before using, or data loss can result. Questions can be asked in the
|
||||
[Rclone Forum](https://forum.rclone.org/).
|
||||
|
||||
See [full bisync description](https://rclone.org/bisync/) for details.
|
||||
`)
|
||||
|
||||
// MakeHelp replaces some dynamic variables for the help docs
|
||||
func MakeHelp(help string) string {
|
||||
replacer := strings.NewReplacer(
|
||||
"||", "`",
|
||||
"{MAXDELETE}", strconv.Itoa(DefaultMaxDelete),
|
||||
"{CHECKFILE}", DefaultCheckFilename,
|
||||
"{WORKDIR}", DefaultWorkdir,
|
||||
)
|
||||
return replacer.Replace(help)
|
||||
}
|
||||
|
||||
func rcBisync(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
opt := &Options{}
|
||||
octx, ci := fs.AddConfig(ctx)
|
||||
@@ -41,56 +83,86 @@ func rcBisync(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
}
|
||||
|
||||
if opt.Resync, err = in.GetBool("resync"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("resync", "optional parameter is missing. using default value: %v", opt.Resync)
|
||||
}
|
||||
if opt.CheckAccess, err = in.GetBool("checkAccess"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("checkAccess", "optional parameter is missing. using default value: %v", opt.CheckAccess)
|
||||
}
|
||||
if opt.Force, err = in.GetBool("force"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("force", "optional parameter is missing. using default value: %v", opt.Force)
|
||||
}
|
||||
if opt.CreateEmptySrcDirs, err = in.GetBool("createEmptySrcDirs"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("createEmptySrcDirs", "optional parameter is missing. using default value: %v", opt.CreateEmptySrcDirs)
|
||||
}
|
||||
if opt.RemoveEmptyDirs, err = in.GetBool("removeEmptyDirs"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("removeEmptyDirs", "optional parameter is missing. using default value: %v", opt.RemoveEmptyDirs)
|
||||
}
|
||||
if opt.NoCleanup, err = in.GetBool("noCleanup"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("noCleanup", "optional parameter is missing. using default value: %v", opt.NoCleanup)
|
||||
}
|
||||
if opt.IgnoreListingChecksum, err = in.GetBool("ignoreListingChecksum"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("ignoreListingChecksum", "optional parameter is missing. using default value: %v", opt.IgnoreListingChecksum)
|
||||
}
|
||||
if opt.Resilient, err = in.GetBool("resilient"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("resilient", "optional parameter is missing. using default value: %v", opt.Resilient)
|
||||
}
|
||||
|
||||
if opt.CheckFilename, err = in.GetString("checkFilename"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
opt.CheckFilename = DefaultCheckFilename
|
||||
fs.Debugf("checkFilename", "optional parameter is missing. using default value: %v", opt.CheckFilename)
|
||||
}
|
||||
if opt.FiltersFile, err = in.GetString("filtersFile"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
fs.Debugf("filtersFile", "optional parameter is missing. using default value: %v", opt.FiltersFile)
|
||||
}
|
||||
if opt.Workdir, err = in.GetString("workdir"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
// "" sets correct default later
|
||||
fs.Debugf("workdir", "optional parameter is missing. using default value: %v", opt.Workdir)
|
||||
}
|
||||
if opt.BackupDir1, err = in.GetString("backupdir1"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
if opt.BackupDir1, err = in.GetString("backupDir1"); rc.NotErrParamNotFound(err) {
|
||||
// we accept an alternate capitalization here for backward compatibility.
|
||||
if opt.BackupDir1, err = in.GetString("backupdir1"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("backupDir1", "optional parameter is missing. using default value: %v", opt.BackupDir1)
|
||||
}
|
||||
}
|
||||
if opt.BackupDir2, err = in.GetString("backupdir2"); rc.NotErrParamNotFound(err) {
|
||||
return
|
||||
if opt.BackupDir2, err = in.GetString("backupDir2"); rc.NotErrParamNotFound(err) {
|
||||
// we accept an alternate capitalization here for backward compatibility.
|
||||
if opt.BackupDir2, err = in.GetString("backupdir2"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("backupDir2", "optional parameter is missing. using default value: %v", opt.BackupDir2)
|
||||
}
|
||||
}
|
||||
|
||||
checkSync, err := in.GetString("checkSync")
|
||||
if rc.NotErrParamNotFound(err) {
|
||||
if err = setEnum(in, "checkSync", "true", opt.CheckSync.Set); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if checkSync == "" {
|
||||
checkSync = "true"
|
||||
}
|
||||
if err := opt.CheckSync.Set(checkSync); err != nil {
|
||||
if err = setEnum(in, "resyncMode", opt.ResyncMode.String(), opt.ResyncMode.Set); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = setEnum(in, "conflictResolve", opt.ConflictResolve.String(), opt.ConflictResolve.Set); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err = setEnum(in, "conflictLoser", opt.ConflictLoser.String(), opt.ConflictLoser.Set); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if opt.ConflictSuffixFlag, err = in.GetString("conflictSuffix"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("conflictSuffix", "optional parameter is missing. using default value: %v", opt.ConflictSuffixFlag)
|
||||
}
|
||||
if opt.Recover, err = in.GetBool("recover"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("recover", "optional parameter is missing. using default value: %v", opt.Recover)
|
||||
}
|
||||
if opt.CompareFlag, err = in.GetString("compare"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("compare", "optional parameter is missing. using default value: %v", opt.CompareFlag)
|
||||
}
|
||||
if opt.Compare.NoSlowHash, err = in.GetBool("noSlowHash"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("noSlowHash", "optional parameter is missing. using default value: %v", opt.Compare.NoSlowHash)
|
||||
}
|
||||
if opt.Compare.SlowHashSyncOnly, err = in.GetBool("slowHashSyncOnly"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("slowHashSyncOnly", "optional parameter is missing. using default value: %v", opt.Compare.SlowHashSyncOnly)
|
||||
}
|
||||
if opt.Compare.DownloadHash, err = in.GetBool("downloadHash"); rc.NotErrParamNotFound(err) {
|
||||
fs.Debugf("downloadHash", "optional parameter is missing. using default value: %v", opt.Compare.DownloadHash)
|
||||
}
|
||||
if opt.MaxLock, err = in.GetFsDuration("maxLock"); rc.NotErrParamNotFound(err) {
|
||||
opt.MaxLock = 0
|
||||
fs.Debugf("maxLock", "optional parameter is missing. using default value: %v", opt.MaxLock)
|
||||
}
|
||||
|
||||
fs1, err := rc.GetFsNamed(octx, in, "path1")
|
||||
if err != nil {
|
||||
@@ -105,6 +177,33 @@ func rcBisync(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||
output := bilib.CaptureOutput(func() {
|
||||
err = Bisync(octx, fs1, fs2, opt)
|
||||
})
|
||||
|
||||
workDir, _ := filepath.Abs(DefaultWorkdir)
|
||||
if opt.Workdir != "" {
|
||||
workDir, _ = filepath.Abs(opt.Workdir)
|
||||
}
|
||||
basePath := bilib.BasePath(ctx, workDir, fs1, fs2)
|
||||
|
||||
_, _ = log.Writer().Write(output)
|
||||
return rc.Params{"output": string(output)}, err
|
||||
return rc.Params{
|
||||
"output": string(output),
|
||||
"session": bilib.SessionName(fs1, fs2),
|
||||
"workDir": workDir,
|
||||
"basePath": basePath,
|
||||
"listing1": basePath + ".path1.lst",
|
||||
"listing2": basePath + ".path2.lst",
|
||||
"logFile": fslog.Opt.File,
|
||||
}, err
|
||||
}
|
||||
|
||||
func setEnum(in rc.Params, name string, defaultVal string, set func(s string) error) error {
|
||||
v, err := in.GetString(name)
|
||||
if rc.NotErrParamNotFound(err) || v == "" {
|
||||
v = defaultVal
|
||||
fs.Debugf(name, "optional parameter is missing. using default value: %v", v)
|
||||
}
|
||||
if err := set(v); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<!--- Docs generated by help.go - use go generate to rebuild - DO NOT EDIT --->
|
||||
|
||||
This takes the following parameters:
|
||||
|
||||
- path1 (required) - (string) a remote directory string e.g. `drive:path1`
|
||||
- path2 (required) - (string) a remote directory string e.g. `drive:path2`
|
||||
- dryRun - (bool) dry-run mode
|
||||
- backupDir1 - (string) --backup-dir for Path1. Must be a non-overlapping path on
|
||||
the same remote.
|
||||
- backupDir2 - (string) --backup-dir for Path2. Must be a non-overlapping path on
|
||||
the same remote.
|
||||
- checkAccess - (bool) Ensure expected RCLONE_TEST files are found on both
|
||||
Path1 and Path2 filesystems, else abort.
|
||||
- checkFilename - (string) Filename for --check-access (default: RCLONE_TEST)
|
||||
- checkSync - (string) Controls comparison of final listings: true|false|only
|
||||
(default: true)
|
||||
- compare - (string) Comma-separated list of bisync-specific compare options ex.
|
||||
'size,modtime,checksum' (default: 'size,modtime')
|
||||
- conflictLoser - (ConflictLoserAction) Action to take on the loser of a sync
|
||||
conflict (when there is a winner) or on both files (when there is no
|
||||
winner): , num, pathname, delete (default: num)
|
||||
- conflictResolve - (string) Automatically resolve conflicts by preferring the
|
||||
version that is: none, path1, path2, newer, older, larger, smaller (default:
|
||||
none)
|
||||
- conflictSuffix - (string) Suffix to use when renaming a --conflict-loser. Can
|
||||
be either one string or two comma-separated strings to assign different
|
||||
suffixes to Path1/Path2. (default: 'conflict')
|
||||
- createEmptySrcDirs - (bool) Sync creation and deletion of empty directories.
|
||||
(Not compatible with --remove-empty-dirs)
|
||||
- downloadHash - (bool) Compute hash by downloading when otherwise
|
||||
unavailable. (warning: may be slow and use lots of data!)
|
||||
- filtersFile - (string) Read filtering patterns from a file
|
||||
- force - (bool) Bypass --max-delete safety check and run the sync. Consider
|
||||
using with --verbose
|
||||
- ignoreListingChecksum - (bool) Do not use checksums for listings (add --ignore-
|
||||
checksum to additionally skip post-copy checksum checks)
|
||||
- maxLock - (Duration) Consider lock files older than this to be expired
|
||||
(default: 0 (never expire)) (minimum: 2m)
|
||||
- noCleanup - (bool) Retain working files (useful for troubleshooting and
|
||||
testing).
|
||||
- noSlowHash - (bool) Ignore listing checksums only on backends where they are
|
||||
slow
|
||||
- recover - (bool) Automatically recover from interruptions without requiring --
|
||||
resync.
|
||||
- removeEmptyDirs - (bool) Remove ALL empty directories at the final cleanup
|
||||
step.
|
||||
- resilient - (bool) Allow future runs to retry after certain less-serious
|
||||
errors, instead of requiring --resync.
|
||||
- resync - (bool) Performs the resync run. Equivalent to --resync-mode path1.
|
||||
Consider using --verbose or --dry-run first.
|
||||
- resyncMode - (string) During resync, prefer the version that is: path1,
|
||||
path2, newer, older, larger, smaller (default: path1 if --resync, otherwise
|
||||
none for no resync.)
|
||||
- slowHashSyncOnly - (bool) Ignore slow checksums for listings and deltas, but
|
||||
still consider them during sync calls.
|
||||
- workdir - (string) Use custom working dir - useful for testing. (default:
|
||||
~/.cache/rclone/bisync)
|
||||
|
||||
See [bisync command help](https://rclone.org/commands/rclone_bisync/)
|
||||
and [full bisync description](https://rclone.org/bisync/)
|
||||
for more information.
|
||||
@@ -1094,3 +1094,4 @@ put them back in again. -->
|
||||
- Bjoern Franke <bjo@schafweide.org>
|
||||
- razorloves <razorloves@gmail.com>
|
||||
- Duncan F <131309315+duncanaf@users.noreply.github.com>
|
||||
- Billy Hughes <w.g.h.hughes@gmail.com>
|
||||
@@ -1897,6 +1897,12 @@ about *Unison* and synchronization in general.
|
||||
|
||||
## Changelog
|
||||
|
||||
### `v1.74`
|
||||
|
||||
- Added several missing `rc` parameters.
|
||||
- Optional `rc` parameters are now truly optional.
|
||||
- `rc` output now provides more structured information.
|
||||
|
||||
### `v1.71`
|
||||
|
||||
- `bisync` is now officially released from beta.
|
||||
|
||||
@@ -6,6 +6,31 @@ description: "Rclone Changelog"
|
||||
|
||||
# Changelog
|
||||
|
||||
## v1.73.2 - 2026-03-06
|
||||
|
||||
[See commits](https://github.com/rclone/rclone/compare/v1.73.1...v1.73.2)
|
||||
|
||||
- Bug Fixes
|
||||
- build
|
||||
- Update to go 1.25.8 to fix CVE-2026-27137 CVE-2026-27138 CVE-2026-25679 CVE-2026-27142 (Nick Craig-Wood)
|
||||
- Update github.com/cloudflare/circl to v1.6.3 to fix CVE-2026-1229 (Nick Craig-Wood)
|
||||
- Update to golang.org/x/net v0.51.0 to fix CVE-2026-27141 (Nick Craig-Wood)
|
||||
- docs fixes:
|
||||
- bisync: Add group Sync to the bisync command (Jan-Philipp Reßler)
|
||||
- Note that --use-server-modtime only works on some backends (Nick Craig-Wood)
|
||||
- Document unsupported S3 object keys with double slashes (Adam Kasztenny)
|
||||
- Fix headers hierarchy for mount.md (Dark Dragon)
|
||||
- Fix new drive flag typo in changelog (razorloves)
|
||||
- Archive
|
||||
- Extract: fix extraction with "./" prefix from tar entry paths (Varun Chawla)
|
||||
- Drime
|
||||
- Fix chunk-uploaded files ignoring workspace ID (a1pcm)
|
||||
- Internxt
|
||||
- Fix Entry doesn't belong in directory errors on windows (jzunigax2)
|
||||
- WebDAV
|
||||
- Escape reserved characters in URL path segments (Varun Chawla)
|
||||
- Add missing headers for CORS (Romāns Potašovs)
|
||||
|
||||
## v1.73.1 - 2026-02-17
|
||||
|
||||
[See commits](https://github.com/rclone/rclone/compare/v1.73.0...v1.73.1)
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
"beta" "This feature is currently in beta must be used with care."
|
||||
}}
|
||||
|
||||
{{ if .Params.versionIntroduced }}<span class="badge badge-pill badge-secondary float-right" style="margin-top: 30px; font-size: 100%" title="This feature needs Rclone {{ .Params.versionIntroduced }} or later.">{{ .Params.versionIntroduced }}</span>{{ end }}
|
||||
{{ if .Params.versionIntroduced }}<span class="badge badge-pill badge-secondary float-right" style="margin-top: 30px; font-size: 100%" title="This feature needs Rclone {{ .Params.versionIntroduced }} or later.">added in {{ .Params.versionIntroduced }}</span>{{ end }}
|
||||
|
||||
{{ with .Params.status | lower }}
|
||||
{{ $statusCode := . }}
|
||||
|
||||
@@ -89,6 +89,7 @@ Returns the following values:
|
||||
{
|
||||
"bytes": total transferred bytes since the start of the group,
|
||||
"checks": number of files checked,
|
||||
"deletedDirs": number of directories deleted,
|
||||
"deletes" : number of files deleted,
|
||||
"elapsedTime": time in floating point seconds since rclone was started,
|
||||
"errors": number of errors,
|
||||
|
||||
@@ -50,6 +50,7 @@ type Sorter struct {
|
||||
errChan <-chan error // for getting errors from the ext sort
|
||||
sorter *extsort.StringSorter // external string sort
|
||||
errs *errcount.ErrCount // accumulate errors
|
||||
tempDir string // directory for temp files (empty for default)
|
||||
}
|
||||
|
||||
// KeyFn turns an entry into a sort key
|
||||
@@ -144,6 +145,7 @@ func (ls *Sorter) startExtSort() (err error) {
|
||||
ChanBuffSize: 1024, // small effect
|
||||
SortedChanBuffSize: 1024, // makes a lot of difference
|
||||
ChunkSize: 32 * 1024, // tuned for 50 char records (UUID sized)
|
||||
TempFilesDir: ls.tempDir,
|
||||
// Defaults
|
||||
// ChunkSize: int(1e6), // amount of records to store in each chunk which will be written to disk
|
||||
// NumWorkers: 2, // maximum number of workers to use for parallel sorting
|
||||
@@ -152,6 +154,17 @@ func (ls *Sorter) startExtSort() (err error) {
|
||||
// TempFilesDir: "", // empty for use OS default ex: /tmp
|
||||
}
|
||||
ls.sorter, ls.outputChan, ls.errChan = extsort.Strings(ls.inputChan, &opt)
|
||||
if ls.sorter == nil {
|
||||
// extsort.Strings returns nil when it can't create temp
|
||||
// files (e.g. due to permissions or apparmor restrictions).
|
||||
// The error will be on errChan.
|
||||
select {
|
||||
case err = <-ls.errChan:
|
||||
default:
|
||||
err = errors.New("failed to initialise on-disk sort")
|
||||
}
|
||||
return fmt.Errorf("sorter: %w", err)
|
||||
}
|
||||
go ls.sorter.Sort(ls.ctx)
|
||||
|
||||
// Show we are extsorting now
|
||||
|
||||
@@ -4,6 +4,9 @@ import (
|
||||
"cmp"
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
"testing"
|
||||
@@ -231,6 +234,51 @@ func TestSorterExt(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// Test that startExtSort returns an error instead of panicking when
|
||||
// temp file creation fails (e.g. due to permissions or apparmor).
|
||||
// See: https://github.com/rclone/rclone/issues/9244
|
||||
func TestSorterExtTempFileError(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
ctx, ci := fs.AddConfig(ctx)
|
||||
ci.ListCutoff = 1 // force ext sort on first Add
|
||||
|
||||
callback := func(entries fs.DirEntries) error {
|
||||
return nil
|
||||
}
|
||||
ls, err := NewSorter(ctx, nil, callback, nil)
|
||||
require.NoError(t, err)
|
||||
defer ls.CleanUp()
|
||||
|
||||
// Override tempDir to a path where os.MkdirAll will fail,
|
||||
// simulating apparmor or permission denial. This makes
|
||||
// extsort.Strings return a nil sorter.
|
||||
if runtime.GOOS == "windows" {
|
||||
// On Windows, create a regular file and use a child path.
|
||||
// os.MkdirAll fails because an intermediate component is a file.
|
||||
// Windows stat returns ERROR_PATH_NOT_FOUND (treated as
|
||||
// IsNotExist) so the extsort library won't fall back to a
|
||||
// default directory.
|
||||
blocker := filepath.Join(t.TempDir(), "notadir")
|
||||
require.NoError(t, os.WriteFile(blocker, []byte("x"), 0644))
|
||||
ls.tempDir = filepath.Join(blocker, "sub")
|
||||
} else {
|
||||
// On Unix, create a read-only parent directory. stat on the
|
||||
// child returns ENOENT so the extsort library won't fall
|
||||
// back, but os.MkdirAll fails with EACCES.
|
||||
parent := filepath.Join(t.TempDir(), "roparent")
|
||||
require.NoError(t, os.Mkdir(parent, 0o755))
|
||||
require.NoError(t, os.Chmod(parent, 0o555))
|
||||
t.Cleanup(func() { _ = os.Chmod(parent, 0o755) })
|
||||
ls.tempDir = filepath.Join(parent, "child")
|
||||
}
|
||||
|
||||
// Add enough entries to trigger ext sort. Before the fix this
|
||||
// would panic with nil pointer dereference.
|
||||
err = ls.Add(fs.DirEntries{mockobject.Object("a"), mockobject.Object("b")})
|
||||
require.Error(t, err)
|
||||
assert.Contains(t, err.Error(), "sorter:")
|
||||
}
|
||||
|
||||
// benchFs implements enough of the fs.Fs interface for Sorter
|
||||
type benchFs struct{}
|
||||
|
||||
|
||||
+41
-21
@@ -125,7 +125,7 @@ type OutputHandler struct {
|
||||
mu sync.Mutex
|
||||
output []outputFn // log to writer if empty or the last item
|
||||
outputExtra []outputExtra // log to all these additional places
|
||||
format logFormat
|
||||
format logFormat // protected by mu
|
||||
jsonBuf bytes.Buffer
|
||||
jsonHandler *slog.JSONHandler
|
||||
}
|
||||
@@ -139,6 +139,13 @@ type outputExtra struct {
|
||||
// Define the type of the override logger
|
||||
type outputFn func(level slog.Level, text string)
|
||||
|
||||
// getFormat returns the current log format flags under the mutex.
|
||||
func (h *OutputHandler) getFormat() logFormat {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
return h.format
|
||||
}
|
||||
|
||||
// NewOutputHandler creates a new OutputHandler with the specified flags.
|
||||
//
|
||||
// This is designed to use log/slog but produce output which is
|
||||
@@ -215,16 +222,22 @@ func (h *OutputHandler) setWriter(writer io.Writer) {
|
||||
|
||||
// Set the format flags to that passed in.
|
||||
func (h *OutputHandler) setFormat(format logFormat) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
h.format = format
|
||||
}
|
||||
|
||||
// clear format flags that this output type doesn't want
|
||||
func (h *OutputHandler) clearFormatFlags(bitMask logFormat) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
h.format &^= bitMask
|
||||
}
|
||||
|
||||
// set format flags that this output type requires
|
||||
func (h *OutputHandler) setFormatFlags(bitMask logFormat) {
|
||||
h.mu.Lock()
|
||||
defer h.mu.Unlock()
|
||||
h.format |= bitMask
|
||||
}
|
||||
|
||||
@@ -238,37 +251,37 @@ func (h *OutputHandler) Enabled(_ context.Context, level slog.Level) bool {
|
||||
}
|
||||
|
||||
// Create a log header in Go standard log format.
|
||||
func (h *OutputHandler) formatStdLogHeader(buf *bytes.Buffer, level slog.Level, t time.Time, object string, lineInfo string) {
|
||||
func (h *OutputHandler) formatStdLogHeader(buf *bytes.Buffer, format logFormat, level slog.Level, t time.Time, object string, lineInfo string) {
|
||||
// Add time in Go standard format if requested
|
||||
if h.format&(logFormatDate|logFormatTime|logFormatMicroseconds) != 0 {
|
||||
if h.format&logFormatUTC != 0 {
|
||||
if format&(logFormatDate|logFormatTime|logFormatMicroseconds) != 0 {
|
||||
if format&logFormatUTC != 0 {
|
||||
t = t.UTC()
|
||||
}
|
||||
if h.format&logFormatDate != 0 {
|
||||
if format&logFormatDate != 0 {
|
||||
year, month, day := t.Date()
|
||||
fmt.Fprintf(buf, "%04d/%02d/%02d ", year, month, day)
|
||||
}
|
||||
if h.format&(logFormatTime|logFormatMicroseconds) != 0 {
|
||||
if format&(logFormatTime|logFormatMicroseconds) != 0 {
|
||||
hour, min, sec := t.Clock()
|
||||
fmt.Fprintf(buf, "%02d:%02d:%02d", hour, min, sec)
|
||||
if h.format&logFormatMicroseconds != 0 {
|
||||
if format&logFormatMicroseconds != 0 {
|
||||
fmt.Fprintf(buf, ".%06d", t.Nanosecond()/1e3)
|
||||
}
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
}
|
||||
// Add source code filename:line if requested
|
||||
if h.format&(logFormatShortFile|logFormatLongFile) != 0 && lineInfo != "" {
|
||||
if format&(logFormatShortFile|logFormatLongFile) != 0 && lineInfo != "" {
|
||||
buf.WriteString(lineInfo)
|
||||
buf.WriteByte(':')
|
||||
buf.WriteByte(' ')
|
||||
}
|
||||
// Add PID if requested
|
||||
if h.format&logFormatPid != 0 {
|
||||
if format&logFormatPid != 0 {
|
||||
fmt.Fprintf(buf, "[%d] ", os.Getpid())
|
||||
}
|
||||
// Add log level if required
|
||||
if h.format&logFormatNoLevel == 0 {
|
||||
if format&logFormatNoLevel == 0 {
|
||||
levelStr := slogLevelToString(level)
|
||||
fmt.Fprintf(buf, "%-6s: ", levelStr)
|
||||
}
|
||||
@@ -281,9 +294,9 @@ func (h *OutputHandler) formatStdLogHeader(buf *bytes.Buffer, level slog.Level,
|
||||
}
|
||||
|
||||
// Create a log in standard Go log format into buf.
|
||||
func (h *OutputHandler) textLog(ctx context.Context, buf *bytes.Buffer, r slog.Record) error {
|
||||
func (h *OutputHandler) textLog(ctx context.Context, buf *bytes.Buffer, format logFormat, r slog.Record) error {
|
||||
var lineInfo string
|
||||
if h.format&(logFormatShortFile|logFormatLongFile) != 0 {
|
||||
if format&(logFormatShortFile|logFormatLongFile) != 0 {
|
||||
lineInfo = getCaller(2)
|
||||
}
|
||||
|
||||
@@ -296,7 +309,7 @@ func (h *OutputHandler) textLog(ctx context.Context, buf *bytes.Buffer, r slog.R
|
||||
return true
|
||||
})
|
||||
|
||||
h.formatStdLogHeader(buf, r.Level, r.Time, object, lineInfo)
|
||||
h.formatStdLogHeader(buf, format, r.Level, r.Time, object, lineInfo)
|
||||
buf.WriteString(r.Message)
|
||||
if buf.Len() == 0 || buf.Bytes()[buf.Len()-1] != '\n' { // Ensure newline
|
||||
buf.WriteByte('\n')
|
||||
@@ -305,13 +318,13 @@ func (h *OutputHandler) textLog(ctx context.Context, buf *bytes.Buffer, r slog.R
|
||||
}
|
||||
|
||||
// Create a log in JSON format into buf.
|
||||
func (h *OutputHandler) jsonLog(ctx context.Context, buf *bytes.Buffer, r slog.Record) (err error) {
|
||||
func (h *OutputHandler) jsonLog(ctx context.Context, buf *bytes.Buffer, format logFormat, r slog.Record) (err error) {
|
||||
// Call the JSON handler to create the JSON in buf
|
||||
r.AddAttrs(
|
||||
slog.String("source", getCaller(2)),
|
||||
)
|
||||
// Add PID if requested
|
||||
if h.format&logFormatPid != 0 {
|
||||
if format&logFormatPid != 0 {
|
||||
r.AddAttrs(slog.Int("pid", os.Getpid()))
|
||||
}
|
||||
h.mu.Lock()
|
||||
@@ -331,8 +344,15 @@ func (h *OutputHandler) Handle(ctx context.Context, r slog.Record) (err error) {
|
||||
buf *bytes.Buffer
|
||||
)
|
||||
|
||||
// Read the format under the mutex once so it is consistent
|
||||
// throughout this call. The mutex is released before calling
|
||||
// jsonLog/textLog (which may re-acquire it) to avoid deadlock.
|
||||
h.mu.Lock()
|
||||
format := h.format
|
||||
h.mu.Unlock()
|
||||
|
||||
// Check whether we need to build Text or JSON logs or both
|
||||
needJSON := h.format&logFormatJSON != 0
|
||||
needJSON := format&logFormatJSON != 0
|
||||
needText := !needJSON
|
||||
for _, out := range h.outputExtra {
|
||||
if out.json {
|
||||
@@ -345,7 +365,7 @@ func (h *OutputHandler) Handle(ctx context.Context, r slog.Record) (err error) {
|
||||
if needJSON {
|
||||
var bufJSONBack [256]byte
|
||||
bufJSON = bytes.NewBuffer(bufJSONBack[:0])
|
||||
err = h.jsonLog(ctx, bufJSON, r)
|
||||
err = h.jsonLog(ctx, bufJSON, format, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -354,7 +374,7 @@ func (h *OutputHandler) Handle(ctx context.Context, r slog.Record) (err error) {
|
||||
if needText {
|
||||
var bufTextBack [256]byte
|
||||
bufText = bytes.NewBuffer(bufTextBack[:0])
|
||||
err = h.textLog(ctx, bufText, r)
|
||||
err = h.textLog(ctx, bufText, format, r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -364,7 +384,7 @@ func (h *OutputHandler) Handle(ctx context.Context, r slog.Record) (err error) {
|
||||
defer h.mu.Unlock()
|
||||
|
||||
// Do the log, either to the default destination or to the alternate logging system
|
||||
if h.format&logFormatJSON != 0 {
|
||||
if format&logFormatJSON != 0 {
|
||||
buf = bufJSON
|
||||
} else {
|
||||
buf = bufText
|
||||
@@ -390,13 +410,13 @@ func (h *OutputHandler) Handle(ctx context.Context, r slog.Record) (err error) {
|
||||
// WithAttrs creates a new handler with the same writer, options, and flags.
|
||||
// Attributes are ignored for the output format of this specific handler.
|
||||
func (h *OutputHandler) WithAttrs(attrs []slog.Attr) slog.Handler {
|
||||
return NewOutputHandler(h.writer, &h.opts, h.format)
|
||||
return NewOutputHandler(h.writer, &h.opts, h.getFormat())
|
||||
}
|
||||
|
||||
// WithGroup creates a new handler with the same writer, options, and flags.
|
||||
// Groups are ignored for the output format of this specific handler.
|
||||
func (h *OutputHandler) WithGroup(name string) slog.Handler {
|
||||
return NewOutputHandler(h.writer, &h.opts, h.format)
|
||||
return NewOutputHandler(h.writer, &h.opts, h.getFormat())
|
||||
}
|
||||
|
||||
// Check interface
|
||||
|
||||
+106
-7
@@ -4,9 +4,11 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -91,9 +93,9 @@ func TestFormatStdLogHeader(t *testing.T) {
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
h := &OutputHandler{format: tc.format}
|
||||
h := NewOutputHandler(&bytes.Buffer{}, nil, tc.format)
|
||||
buf := &bytes.Buffer{}
|
||||
h.formatStdLogHeader(buf, slog.LevelInfo, t0, tc.object, tc.lineInfo)
|
||||
h.formatStdLogHeader(buf, tc.format, slog.LevelInfo, t0, tc.object, tc.lineInfo)
|
||||
if !strings.HasPrefix(buf.String(), tc.wantPrefix) {
|
||||
t.Errorf("%s: got %q; want prefix %q", tc.name, buf.String(), tc.wantPrefix)
|
||||
}
|
||||
@@ -114,13 +116,13 @@ func TestEnabled(t *testing.T) {
|
||||
|
||||
// Test clearFormatFlags and setFormatFlags bitwise ops.
|
||||
func TestClearSetFormatFlags(t *testing.T) {
|
||||
h := &OutputHandler{format: logFormatDate | logFormatTime}
|
||||
h := NewOutputHandler(&bytes.Buffer{}, nil, logFormatDate|logFormatTime)
|
||||
|
||||
h.clearFormatFlags(logFormatTime)
|
||||
assert.True(t, h.format&logFormatTime == 0)
|
||||
assert.True(t, h.getFormat()&logFormatTime == 0)
|
||||
|
||||
h.setFormatFlags(logFormatMicroseconds)
|
||||
assert.True(t, h.format&logFormatMicroseconds != 0)
|
||||
assert.True(t, h.getFormat()&logFormatMicroseconds != 0)
|
||||
}
|
||||
|
||||
// Test SetOutput and ResetOutput override the default writer.
|
||||
@@ -231,7 +233,7 @@ func TestTextLogAndJsonLog(t *testing.T) {
|
||||
|
||||
// textLog
|
||||
bufText := &bytes.Buffer{}
|
||||
require.NoError(t, h.textLog(context.Background(), bufText, r))
|
||||
require.NoError(t, h.textLog(context.Background(), bufText, h.getFormat(), r))
|
||||
out := bufText.String()
|
||||
if !strings.Contains(out, "WARNING") || !strings.Contains(out, "obj:") || !strings.HasSuffix(out, "\n") {
|
||||
t.Errorf("textLog output = %q", out)
|
||||
@@ -239,13 +241,110 @@ func TestTextLogAndJsonLog(t *testing.T) {
|
||||
|
||||
// jsonLog
|
||||
bufJSON := &bytes.Buffer{}
|
||||
require.NoError(t, h.jsonLog(context.Background(), bufJSON, r))
|
||||
require.NoError(t, h.jsonLog(context.Background(), bufJSON, h.getFormat(), r))
|
||||
j := bufJSON.String()
|
||||
if !strings.Contains(j, `"level":"warning"`) || !strings.Contains(j, `"msg":"msg!"`) {
|
||||
t.Errorf("jsonLog output = %q", j)
|
||||
}
|
||||
}
|
||||
|
||||
// Test concurrent access to the handler does not race or deadlock.
|
||||
func TestOutputHandlerConcurrency(t *testing.T) {
|
||||
h := NewOutputHandler(io.Discard, nil, logFormatDate|logFormatTime)
|
||||
ctx := context.Background()
|
||||
|
||||
const goroutines = 10
|
||||
const iterations = 500
|
||||
|
||||
var wg sync.WaitGroup
|
||||
|
||||
// Goroutines calling Handle (text format)
|
||||
for i := 0; i < goroutines; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
r := slog.NewRecord(t0, slog.LevelInfo, "concurrent text", 0)
|
||||
r.AddAttrs(slog.String("object", "obj"))
|
||||
_ = h.Handle(ctx, r)
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Goroutines calling setFormat (switching between text and JSON)
|
||||
for i := 0; i < 2; i++ {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
if j%2 == 0 {
|
||||
h.setFormat(logFormatDate | logFormatTime)
|
||||
} else {
|
||||
h.setFormat(logFormatJSON)
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Goroutines calling setFormatFlags / clearFormatFlags
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
h.setFormatFlags(logFormatPid | logFormatMicroseconds)
|
||||
h.clearFormatFlags(logFormatPid | logFormatMicroseconds)
|
||||
}
|
||||
}()
|
||||
|
||||
// Goroutines calling SetLevel
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
if j%2 == 0 {
|
||||
h.SetLevel(slog.LevelDebug)
|
||||
} else {
|
||||
h.SetLevel(slog.LevelInfo)
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
// Goroutines calling SetOutput / ResetOutput
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
noop := func(_ slog.Level, _ string) {}
|
||||
for j := 0; j < iterations; j++ {
|
||||
h.SetOutput(noop)
|
||||
h.ResetOutput()
|
||||
}
|
||||
}()
|
||||
|
||||
// Goroutines calling WithAttrs / WithGroup (reads format)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
for j := 0; j < iterations; j++ {
|
||||
_ = h.WithAttrs(nil)
|
||||
_ = h.WithGroup("g")
|
||||
}
|
||||
}()
|
||||
|
||||
// Use a channel with a timeout to detect deadlocks
|
||||
done := make(chan struct{})
|
||||
go func() {
|
||||
wg.Wait()
|
||||
close(done)
|
||||
}()
|
||||
|
||||
select {
|
||||
case <-done:
|
||||
// success
|
||||
case <-time.After(30 * time.Second):
|
||||
t.Fatal("timed out waiting for concurrent goroutines — probable deadlock")
|
||||
}
|
||||
}
|
||||
|
||||
// Table-driven test for JSON vs text Handle behavior.
|
||||
func TestHandleFormatFlags(t *testing.T) {
|
||||
r := slog.NewRecord(t0, slog.LevelInfo, "hi", 0)
|
||||
|
||||
@@ -60,6 +60,7 @@ require (
|
||||
github.com/minio/minio-go/v7 v7.0.98
|
||||
github.com/mitchellh/go-homedir v1.1.0
|
||||
github.com/moby/sys/mountinfo v0.7.2
|
||||
github.com/muesli/reflow v0.3.0
|
||||
github.com/ncw/swift/v2 v2.0.5
|
||||
github.com/oracle/oci-go-sdk/v65 v65.108.2
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
|
||||
@@ -499,6 +499,7 @@ github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stg
|
||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
|
||||
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
|
||||
github.com/mattn/go-runewidth v0.0.20 h1:WcT52H91ZUAwy8+HUkdM3THM6gXqXuLJi9O3rjcQQaQ=
|
||||
github.com/mattn/go-runewidth v0.0.20/go.mod h1:XBkDxAl56ILZc9knddidhrOlY5R/pDhgLpndooCuJAs=
|
||||
github.com/mholt/archives v0.1.5 h1:Fh2hl1j7VEhc6DZs2DLMgiBNChUux154a1G+2esNvzQ=
|
||||
@@ -523,6 +524,8 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
|
||||
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
|
||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
|
||||
github.com/ncw/swift/v2 v2.0.5 h1:9o5Gsd7bInAFEqsGPcaUdsboMbqf8lnNtxqWKFT9iz8=
|
||||
@@ -598,6 +601,8 @@ github.com/relvacode/iso8601 v1.7.0 h1:BXy+V60stMP6cpswc+a93Mq3e65PfXCgDFfhvNNGr
|
||||
github.com/relvacode/iso8601 v1.7.0/go.mod h1:FlNp+jz+TXpyRqgmM7tnzHHzBnz776kmAH2h3sZCn0I=
|
||||
github.com/rfjakob/eme v1.2.0 h1:8dAHL+WVAw06+7DkRKnRiFp1JL3QjcJEZFqDnndUaSI=
|
||||
github.com/rfjakob/eme v1.2.0/go.mod h1:cVvpasglm/G3ngEfcfT/Wt0GwhkuO32pf/poW6Nyk1k=
|
||||
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
|
||||
Reference in new issue
Block a user