mirror of
https://github.com/rclone/rclone.git
synced 2024-11-07 09:04:52 +01:00
Fix lint issues reported by staticcheck
Used staticcheck 2022.1.2 (v0.3.2) See: staticcheck.io
This commit is contained in:
parent
74bd7f3381
commit
ec117593f1
@ -435,7 +435,7 @@ func (f *Fs) listAll(ctx context.Context, dirID string, title string, directorie
|
|||||||
query += " AND kind:" + folderKind
|
query += " AND kind:" + folderKind
|
||||||
} else if filesOnly {
|
} else if filesOnly {
|
||||||
query += " AND kind:" + fileKind
|
query += " AND kind:" + fileKind
|
||||||
} else {
|
//} else {
|
||||||
// FIXME none of these work
|
// FIXME none of these work
|
||||||
//query += " AND kind:(" + fileKind + " OR " + folderKind + ")"
|
//query += " AND kind:(" + fileKind + " OR " + folderKind + ")"
|
||||||
//query += " AND (kind:" + fileKind + " OR kind:" + folderKind + ")"
|
//query += " AND (kind:" + fileKind + " OR kind:" + folderKind + ")"
|
||||||
|
@ -280,7 +280,7 @@ func (f *Fs) Root() string {
|
|||||||
// String converts this Fs to a string
|
// String converts this Fs to a string
|
||||||
func (f *Fs) String() string {
|
func (f *Fs) String() string {
|
||||||
if f.rootBucket == "" {
|
if f.rootBucket == "" {
|
||||||
return fmt.Sprintf("B2 root")
|
return "B2 root"
|
||||||
}
|
}
|
||||||
if f.rootDirectory == "" {
|
if f.rootDirectory == "" {
|
||||||
return fmt.Sprintf("B2 bucket %s", f.rootBucket)
|
return fmt.Sprintf("B2 bucket %s", f.rootBucket)
|
||||||
@ -1205,10 +1205,7 @@ func (f *Fs) purge(ctx context.Context, dir string, oldOnly bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var isUnfinishedUploadStale = func(timestamp api.Timestamp) bool {
|
var isUnfinishedUploadStale = func(timestamp api.Timestamp) bool {
|
||||||
if time.Since(time.Time(timestamp)).Hours() > 24 {
|
return time.Since(time.Time(timestamp)).Hours() > 24
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete Config.Transfers in parallel
|
// Delete Config.Transfers in parallel
|
||||||
@ -1485,13 +1482,9 @@ func (o *Object) Size() int64 {
|
|||||||
//
|
//
|
||||||
// Remove unverified prefix - see https://www.backblaze.com/b2/docs/uploading.html
|
// Remove unverified prefix - see https://www.backblaze.com/b2/docs/uploading.html
|
||||||
// Some tools (e.g. Cyberduck) use this
|
// Some tools (e.g. Cyberduck) use this
|
||||||
func cleanSHA1(sha1 string) (out string) {
|
func cleanSHA1(sha1 string) string {
|
||||||
out = strings.ToLower(sha1)
|
|
||||||
const unverified = "unverified:"
|
const unverified = "unverified:"
|
||||||
if strings.HasPrefix(out, unverified) {
|
return strings.TrimPrefix(strings.ToLower(sha1), unverified)
|
||||||
out = out[len(unverified):]
|
|
||||||
}
|
|
||||||
return out
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// decodeMetaDataRaw sets the metadata from the data passed in
|
// decodeMetaDataRaw sets the metadata from the data passed in
|
||||||
|
@ -897,7 +897,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
|
|
||||||
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
||||||
dstPath := f.rootSlash() + remote
|
dstPath := f.rootSlash() + remote
|
||||||
if strings.ToLower(srcPath) == strings.ToLower(dstPath) {
|
if strings.EqualFold(srcPath, dstPath) {
|
||||||
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
backend/cache/storage_memory.go
vendored
5
backend/cache/storage_memory.go
vendored
@ -76,10 +76,7 @@ func (m *Memory) CleanChunksByAge(chunkAge time.Duration) {
|
|||||||
|
|
||||||
// CleanChunksByNeed will cleanup chunks after the FS passes a specific chunk
|
// CleanChunksByNeed will cleanup chunks after the FS passes a specific chunk
|
||||||
func (m *Memory) CleanChunksByNeed(offset int64) {
|
func (m *Memory) CleanChunksByNeed(offset int64) {
|
||||||
var items map[string]cache.Item
|
for key := range m.db.Items() {
|
||||||
|
|
||||||
items = m.db.Items()
|
|
||||||
for key := range items {
|
|
||||||
sepIdx := strings.LastIndex(key, "-")
|
sepIdx := strings.LastIndex(key, "-")
|
||||||
keyOffset, err := strconv.ParseInt(key[sepIdx+1:], 10, 64)
|
keyOffset, err := strconv.ParseInt(key[sepIdx+1:], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
5
backend/cache/storage_persistent.go
vendored
5
backend/cache/storage_persistent.go
vendored
@ -456,10 +456,7 @@ func (b *Persistent) HasEntry(remote string) bool {
|
|||||||
|
|
||||||
return fmt.Errorf("couldn't find object (%v)", remote)
|
return fmt.Errorf("couldn't find object (%v)", remote)
|
||||||
})
|
})
|
||||||
if err == nil {
|
return err == nil
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// HasChunk confirms the existence of a single chunk of an object
|
// HasChunk confirms the existence of a single chunk of an object
|
||||||
|
@ -195,7 +195,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (outFs fs
|
|||||||
if remote == "" {
|
if remote == "" {
|
||||||
return fmt.Errorf("empty remote in upstream definition %q", upstream)
|
return fmt.Errorf("empty remote in upstream definition %q", upstream)
|
||||||
}
|
}
|
||||||
if strings.IndexRune(dir, '/') >= 0 {
|
if strings.ContainsRune(dir, '/') {
|
||||||
return fmt.Errorf("dirs can't contain / (yet): %q", dir)
|
return fmt.Errorf("dirs can't contain / (yet): %q", dir)
|
||||||
}
|
}
|
||||||
u, err := f.newUpstream(gCtx, dir, remote)
|
u, err := f.newUpstream(gCtx, dir, remote)
|
||||||
|
@ -53,7 +53,7 @@ const (
|
|||||||
Gzip = 2
|
Gzip = 2
|
||||||
)
|
)
|
||||||
|
|
||||||
var nameRegexp = regexp.MustCompile("^(.+?)\\.([A-Za-z0-9-_]{11})$")
|
var nameRegexp = regexp.MustCompile(`^(.+?)\.([A-Za-z0-9-_]{11})$`)
|
||||||
|
|
||||||
// Register with Fs
|
// Register with Fs
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -2020,7 +2020,7 @@ func splitID(compositeID string) (actualID, shortcutID string) {
|
|||||||
|
|
||||||
// isShortcutID returns true if compositeID refers to a shortcut
|
// isShortcutID returns true if compositeID refers to a shortcut
|
||||||
func isShortcutID(compositeID string) bool {
|
func isShortcutID(compositeID string) bool {
|
||||||
return strings.IndexRune(compositeID, shortcutSeparator) >= 0
|
return strings.ContainsRune(compositeID, shortcutSeparator)
|
||||||
}
|
}
|
||||||
|
|
||||||
// actualID returns an actual ID from a composite ID
|
// actualID returns an actual ID from a composite ID
|
||||||
@ -3327,7 +3327,7 @@ func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[str
|
|||||||
out["service_account_file"] = f.opt.ServiceAccountFile
|
out["service_account_file"] = f.opt.ServiceAccountFile
|
||||||
}
|
}
|
||||||
if _, ok := opt["chunk_size"]; ok {
|
if _, ok := opt["chunk_size"]; ok {
|
||||||
out["chunk_size"] = fmt.Sprintf("%s", f.opt.ChunkSize)
|
out["chunk_size"] = f.opt.ChunkSize.String()
|
||||||
}
|
}
|
||||||
return out, nil
|
return out, nil
|
||||||
case "set":
|
case "set":
|
||||||
@ -3344,11 +3344,11 @@ func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[str
|
|||||||
}
|
}
|
||||||
if chunkSize, ok := opt["chunk_size"]; ok {
|
if chunkSize, ok := opt["chunk_size"]; ok {
|
||||||
chunkSizeMap := make(map[string]string)
|
chunkSizeMap := make(map[string]string)
|
||||||
chunkSizeMap["previous"] = fmt.Sprintf("%s", f.opt.ChunkSize)
|
chunkSizeMap["previous"] = f.opt.ChunkSize.String()
|
||||||
if err = f.changeChunkSize(chunkSize); err != nil {
|
if err = f.changeChunkSize(chunkSize); err != nil {
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
chunkSizeString := fmt.Sprintf("%s", f.opt.ChunkSize)
|
chunkSizeString := f.opt.ChunkSize.String()
|
||||||
f.m.Set("chunk_size", chunkSizeString)
|
f.m.Set("chunk_size", chunkSizeString)
|
||||||
chunkSizeMap["current"] = chunkSizeString
|
chunkSizeMap["current"] = chunkSizeString
|
||||||
out["chunk_size"] = chunkSizeMap
|
out["chunk_size"] = chunkSizeMap
|
||||||
@ -3392,13 +3392,13 @@ func (f *Fs) Command(ctx context.Context, name string, arg []string, opt map[str
|
|||||||
names[name] = struct{}{}
|
names[name] = struct{}{}
|
||||||
lines = append(lines, "")
|
lines = append(lines, "")
|
||||||
lines = append(lines, fmt.Sprintf("[%s]", name))
|
lines = append(lines, fmt.Sprintf("[%s]", name))
|
||||||
lines = append(lines, fmt.Sprintf("type = alias"))
|
lines = append(lines, "type = alias")
|
||||||
lines = append(lines, fmt.Sprintf("remote = %s,team_drive=%s,root_folder_id=:", f.name, drive.Id))
|
lines = append(lines, fmt.Sprintf("remote = %s,team_drive=%s,root_folder_id=:", f.name, drive.Id))
|
||||||
upstreams = append(upstreams, fmt.Sprintf(`"%s=%s:"`, name, name))
|
upstreams = append(upstreams, fmt.Sprintf(`"%s=%s:"`, name, name))
|
||||||
}
|
}
|
||||||
lines = append(lines, "")
|
lines = append(lines, "")
|
||||||
lines = append(lines, fmt.Sprintf("[AllDrives]"))
|
lines = append(lines, "[AllDrives]")
|
||||||
lines = append(lines, fmt.Sprintf("type = combine"))
|
lines = append(lines, "type = combine")
|
||||||
lines = append(lines, fmt.Sprintf("upstreams = %s", strings.Join(upstreams, " ")))
|
lines = append(lines, fmt.Sprintf("upstreams = %s", strings.Join(upstreams, " ")))
|
||||||
return lines, nil
|
return lines, nil
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
// Root is a dir - cache its ID
|
// Root is a dir - cache its ID
|
||||||
f.dirCache.Put(f.root, info.ID)
|
f.dirCache.Put(f.root, info.ID)
|
||||||
}
|
}
|
||||||
} else {
|
//} else {
|
||||||
// Root is not found so a directory
|
// Root is not found so a directory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -391,7 +391,7 @@ func (f *Fs) Root() string {
|
|||||||
// String converts this Fs to a string
|
// String converts this Fs to a string
|
||||||
func (f *Fs) String() string {
|
func (f *Fs) String() string {
|
||||||
if f.rootBucket == "" {
|
if f.rootBucket == "" {
|
||||||
return fmt.Sprintf("GCS root")
|
return "GCS root"
|
||||||
}
|
}
|
||||||
if f.rootDirectory == "" {
|
if f.rootDirectory == "" {
|
||||||
return fmt.Sprintf("GCS bucket %s", f.rootBucket)
|
return fmt.Sprintf("GCS bucket %s", f.rootBucket)
|
||||||
|
@ -37,7 +37,7 @@ func TestIntegration(t *testing.T) {
|
|||||||
}
|
}
|
||||||
f, err := fs.NewFs(ctx, *fstest.RemoteName)
|
f, err := fs.NewFs(ctx, *fstest.RemoteName)
|
||||||
if err == fs.ErrorNotFoundInConfigFile {
|
if err == fs.ErrorNotFoundInConfigFile {
|
||||||
t.Skip(fmt.Sprintf("Couldn't create google photos backend - skipping tests: %v", err))
|
t.Skipf("Couldn't create google photos backend - skipping tests: %v", err)
|
||||||
}
|
}
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ func (f *testLister) listAlbums(ctx context.Context, shared bool) (all *albums,
|
|||||||
|
|
||||||
// mock listUploads for testing
|
// mock listUploads for testing
|
||||||
func (f *testLister) listUploads(ctx context.Context, dir string) (entries fs.DirEntries, err error) {
|
func (f *testLister) listUploads(ctx context.Context, dir string) (entries fs.DirEntries, err error) {
|
||||||
entries, _ = f.uploaded[dir]
|
entries = f.uploaded[dir]
|
||||||
return entries, nil
|
return entries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := o.fs.client.Stat(realpath)
|
_, err = o.fs.client.Stat(realpath)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = o.fs.client.Remove(realpath)
|
err = o.fs.client.Remove(realpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -147,7 +147,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err = o.fs.client.Stat(realpath)
|
info, err := o.fs.client.Stat(realpath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -138,7 +138,7 @@ func (f *Fs) getCredentials(ctx context.Context) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
f.expires = expires
|
f.expires = expires
|
||||||
fs.Debugf(f, "Got swift credentials (expiry %v in %v)", f.expires, f.expires.Sub(time.Now()))
|
fs.Debugf(f, "Got swift credentials (expiry %v in %v)", f.expires, time.Until(f.expires))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1252,10 +1252,7 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
|
|||||||
func (f *Fs) mkParentDir(ctx context.Context, dirPath string) error {
|
func (f *Fs) mkParentDir(ctx context.Context, dirPath string) error {
|
||||||
// defer log.Trace(dirPath, "")("")
|
// defer log.Trace(dirPath, "")("")
|
||||||
// chop off trailing / if it exists
|
// chop off trailing / if it exists
|
||||||
if strings.HasSuffix(dirPath, "/") {
|
parent := path.Dir(strings.TrimSuffix(dirPath, "/"))
|
||||||
dirPath = dirPath[:len(dirPath)-1]
|
|
||||||
}
|
|
||||||
parent := path.Dir(dirPath)
|
|
||||||
if parent == "." {
|
if parent == "." {
|
||||||
parent = ""
|
parent = ""
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,12 @@ var getFreeDiskSpace = syscall.NewLazyDLL("kernel32.dll").NewProc("GetDiskFreeSp
|
|||||||
// About gets quota information
|
// About gets quota information
|
||||||
func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
|
func (f *Fs) About(ctx context.Context) (*fs.Usage, error) {
|
||||||
var available, total, free int64
|
var available, total, free int64
|
||||||
|
root, e := syscall.UTF16PtrFromString(f.root)
|
||||||
|
if e != nil {
|
||||||
|
return nil, fmt.Errorf("failed to read disk usage: %w", e)
|
||||||
|
}
|
||||||
_, _, e1 := getFreeDiskSpace.Call(
|
_, _, e1 := getFreeDiskSpace.Call(
|
||||||
uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(f.root))),
|
uintptr(unsafe.Pointer(root)),
|
||||||
uintptr(unsafe.Pointer(&available)), // lpFreeBytesAvailable - for this user
|
uintptr(unsafe.Pointer(&available)), // lpFreeBytesAvailable - for this user
|
||||||
uintptr(unsafe.Pointer(&total)), // lpTotalNumberOfBytes
|
uintptr(unsafe.Pointer(&total)), // lpTotalNumberOfBytes
|
||||||
uintptr(unsafe.Pointer(&free)), // lpTotalNumberOfFreeBytes
|
uintptr(unsafe.Pointer(&free)), // lpTotalNumberOfFreeBytes
|
||||||
|
@ -1723,7 +1723,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if bytes.Compare(fileHash, newHash) != 0 {
|
if !bytes.Equal(fileHash, newHash) {
|
||||||
if o.fs.opt.CheckHash {
|
if o.fs.opt.CheckHash {
|
||||||
return mrhash.ErrorInvalidHash
|
return mrhash.ErrorInvalidHash
|
||||||
}
|
}
|
||||||
@ -2262,7 +2262,7 @@ func (e *endHandler) handle(err error) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
newHash := e.hasher.Sum(nil)
|
newHash := e.hasher.Sum(nil)
|
||||||
if bytes.Compare(o.mrHash, newHash) == 0 {
|
if bytes.Equal(o.mrHash, newHash) {
|
||||||
return io.EOF
|
return io.EOF
|
||||||
}
|
}
|
||||||
if o.fs.opt.CheckHash {
|
if o.fs.opt.CheckHash {
|
||||||
|
@ -903,22 +903,20 @@ func (f *Fs) netStorageStatRequest(ctx context.Context, URL string, directory bo
|
|||||||
files = statResp.Files
|
files = statResp.Files
|
||||||
f.setStatCache(URL, files)
|
f.setStatCache(URL, files)
|
||||||
}
|
}
|
||||||
if files != nil {
|
// Multiple objects can be returned with the "slash=both" option,
|
||||||
// Multiple objects can be returned with the "slash=both" option,
|
// when file/symlink/directory has the same name
|
||||||
// when file/symlink/directory has the same name
|
for i := range files {
|
||||||
for i := range files {
|
if files[i].Type == "symlink" {
|
||||||
if files[i].Type == "symlink" {
|
// Add .rclonelink suffix to allow local backend code to convert to a symlink.
|
||||||
// Add .rclonelink suffix to allow local backend code to convert to a symlink.
|
files[i].Name += ".rclonelink"
|
||||||
files[i].Name += ".rclonelink"
|
fs.Infof(nil, "Converting a symlink to the rclonelink on the stat request %s", files[i].Name)
|
||||||
fs.Infof(nil, "Converting a symlink to the rclonelink on the stat request %s", files[i].Name)
|
}
|
||||||
}
|
entrywanted := (directory && files[i].Type == "dir") ||
|
||||||
entrywanted := (directory && files[i].Type == "dir") ||
|
(!directory && files[i].Type != "dir")
|
||||||
(!directory && files[i].Type != "dir")
|
if entrywanted {
|
||||||
if entrywanted {
|
filestamp := files[0]
|
||||||
filestamp := files[0]
|
files[0] = files[i]
|
||||||
files[0] = files[i]
|
files[i] = filestamp
|
||||||
files[i] = filestamp
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return files, nil
|
return files, nil
|
||||||
|
@ -292,7 +292,7 @@ type AsyncOperationStatus struct {
|
|||||||
func (i *Item) GetID() string {
|
func (i *Item) GetID() string {
|
||||||
if i.IsRemote() && i.RemoteItem.ID != "" {
|
if i.IsRemote() && i.RemoteItem.ID != "" {
|
||||||
return i.RemoteItem.ParentReference.DriveID + "#" + i.RemoteItem.ID
|
return i.RemoteItem.ParentReference.DriveID + "#" + i.RemoteItem.ID
|
||||||
} else if i.ParentReference != nil && strings.Index(i.ID, "#") == -1 {
|
} else if i.ParentReference != nil && !strings.Contains(i.ID, "#") {
|
||||||
return i.ParentReference.DriveID + "#" + i.ID
|
return i.ParentReference.DriveID + "#" + i.ID
|
||||||
}
|
}
|
||||||
return i.ID
|
return i.ID
|
||||||
|
@ -660,7 +660,7 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 401:
|
case 401:
|
||||||
if len(resp.Header["Www-Authenticate"]) == 1 && strings.Index(resp.Header["Www-Authenticate"][0], "expired_token") >= 0 {
|
if len(resp.Header["Www-Authenticate"]) == 1 && strings.Contains(resp.Header["Www-Authenticate"][0], "expired_token") {
|
||||||
retry = true
|
retry = true
|
||||||
fs.Debugf(nil, "Should retry: %v", err)
|
fs.Debugf(nil, "Should retry: %v", err)
|
||||||
} else if err != nil && strings.Contains(err.Error(), "Unable to initialize RPS") {
|
} else if err != nil && strings.Contains(err.Error(), "Unable to initialize RPS") {
|
||||||
@ -716,8 +716,7 @@ func (f *Fs) readMetaDataForPath(ctx context.Context, path string) (info *api.It
|
|||||||
firstSlashIndex := strings.IndexRune(path, '/')
|
firstSlashIndex := strings.IndexRune(path, '/')
|
||||||
|
|
||||||
if f.driveType != driveTypePersonal || firstSlashIndex == -1 {
|
if f.driveType != driveTypePersonal || firstSlashIndex == -1 {
|
||||||
var opts rest.Opts
|
opts := f.newOptsCallWithPath(ctx, path, "GET", "")
|
||||||
opts = f.newOptsCallWithPath(ctx, path, "GET", "")
|
|
||||||
opts.Path = strings.TrimSuffix(opts.Path, ":")
|
opts.Path = strings.TrimSuffix(opts.Path, ":")
|
||||||
err = f.pacer.Call(func() (bool, error) {
|
err = f.pacer.Call(func() (bool, error) {
|
||||||
resp, err = f.srv.CallJSON(ctx, &opts, nil, &info)
|
resp, err = f.srv.CallJSON(ctx, &opts, nil, &info)
|
||||||
@ -1287,7 +1286,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
if srcObj.fs == f {
|
if srcObj.fs == f {
|
||||||
srcPath := srcObj.rootPath()
|
srcPath := srcObj.rootPath()
|
||||||
dstPath := f.rootPath(remote)
|
dstPath := f.rootPath(remote)
|
||||||
if strings.ToLower(srcPath) == strings.ToLower(dstPath) {
|
if strings.EqualFold(srcPath, dstPath) {
|
||||||
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2185,7 +2184,7 @@ func (o *Object) ID() string {
|
|||||||
// Such a normalized ID can come from (*Item).GetID()
|
// Such a normalized ID can come from (*Item).GetID()
|
||||||
func (f *Fs) parseNormalizedID(ID string) (string, string, string) {
|
func (f *Fs) parseNormalizedID(ID string) (string, string, string) {
|
||||||
rootURL := graphAPIEndpoint[f.opt.Region] + "/v1.0/drives"
|
rootURL := graphAPIEndpoint[f.opt.Region] + "/v1.0/drives"
|
||||||
if strings.Index(ID, "#") >= 0 {
|
if strings.Contains(ID, "#") {
|
||||||
s := strings.Split(ID, "#")
|
s := strings.Split(ID, "#")
|
||||||
return s[1], s[0], rootURL
|
return s[1], s[0], rootURL
|
||||||
}
|
}
|
||||||
@ -2359,6 +2358,9 @@ func (f *Fs) ChangeNotify(ctx context.Context, notifyFunc func(string, fs.EntryT
|
|||||||
|
|
||||||
func (f *Fs) changeNotifyStartPageToken(ctx context.Context) (nextDeltaToken string, err error) {
|
func (f *Fs) changeNotifyStartPageToken(ctx context.Context) (nextDeltaToken string, err error) {
|
||||||
delta, err := f.changeNotifyNextChange(ctx, "latest")
|
delta, err := f.changeNotifyNextChange(ctx, "latest")
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
parsedURL, err := url.Parse(delta.DeltaLink)
|
parsedURL, err := url.Parse(delta.DeltaLink)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -2388,6 +2390,9 @@ func (f *Fs) buildDriveDeltaOpts(token string) rest.Opts {
|
|||||||
|
|
||||||
func (f *Fs) changeNotifyRunner(ctx context.Context, notifyFunc func(string, fs.EntryType), deltaToken string) (nextDeltaToken string, err error) {
|
func (f *Fs) changeNotifyRunner(ctx context.Context, notifyFunc func(string, fs.EntryType), deltaToken string) (nextDeltaToken string, err error) {
|
||||||
delta, err := f.changeNotifyNextChange(ctx, deltaToken)
|
delta, err := f.changeNotifyNextChange(ctx, deltaToken)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
parsedURL, err := url.Parse(delta.DeltaLink)
|
parsedURL, err := url.Parse(delta.DeltaLink)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
@ -361,7 +361,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
|
|
||||||
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
||||||
dstPath := f.rootSlash() + remote
|
dstPath := f.rootSlash() + remote
|
||||||
if strings.ToLower(srcPath) == strings.ToLower(dstPath) {
|
if strings.EqualFold(srcPath, dstPath) {
|
||||||
return nil, fmt.Errorf("Can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
return nil, fmt.Errorf("Can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -588,9 +588,6 @@ func (f *Fs) readMetaDataForFolderID(ctx context.Context, id string) (info *Fold
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if resp != nil {
|
|
||||||
}
|
|
||||||
|
|
||||||
return info, err
|
return info, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -611,13 +608,13 @@ func (f *Fs) Put(ctx context.Context, in io.Reader, src fs.ObjectInfo, options .
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if "" == o.id {
|
if o.id == "" {
|
||||||
// Attempt to read ID, ignore error
|
// Attempt to read ID, ignore error
|
||||||
// FIXME is this correct?
|
// FIXME is this correct?
|
||||||
_ = o.readMetaData(ctx)
|
_ = o.readMetaData(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
if "" == o.id {
|
if o.id == "" {
|
||||||
// We need to create an ID for this file
|
// We need to create an ID for this file
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
response := createFileResponse{}
|
response := createFileResponse{}
|
||||||
|
@ -136,7 +136,7 @@ func (g *GetFileLinkResult) IsValid() bool {
|
|||||||
if len(g.Hosts) == 0 {
|
if len(g.Hosts) == 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return time.Time(g.Expires).Sub(time.Now()) > 30*time.Second
|
return time.Until(time.Time(g.Expires)) > 30*time.Second
|
||||||
}
|
}
|
||||||
|
|
||||||
// URL returns a URL from the Path and Hosts. Check with IsValid
|
// URL returns a URL from the Path and Hosts. Check with IsValid
|
||||||
|
@ -227,7 +227,7 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Index(resp.Header["Www-Authenticate"][0], "expired_token") >= 0 {
|
if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Contains(resp.Header["Www-Authenticate"][0], "expired_token") {
|
||||||
doRetry = true
|
doRetry = true
|
||||||
fs.Debugf(nil, "Should retry: %v", err)
|
fs.Debugf(nil, "Should retry: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -573,9 +573,7 @@ func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBuck
|
|||||||
if addBucket {
|
if addBucket {
|
||||||
remote = path.Join(bucket, remote)
|
remote = path.Join(bucket, remote)
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(remote, "/") {
|
remote = strings.TrimSuffix(remote, "/")
|
||||||
remote = remote[:len(remote)-1]
|
|
||||||
}
|
|
||||||
err = fn(remote, &qs.KeyType{Key: &remote}, true)
|
err = fn(remote, &qs.KeyType{Key: &remote}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -775,8 +773,6 @@ func (f *Fs) makeBucket(ctx context.Context, bucket string) error {
|
|||||||
retries++
|
retries++
|
||||||
wasDeleted = true
|
wasDeleted = true
|
||||||
continue
|
continue
|
||||||
default:
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
@ -854,7 +850,6 @@ func (f *Fs) Rmdir(ctx context.Context, dir string) error {
|
|||||||
continue
|
continue
|
||||||
default:
|
default:
|
||||||
err = e
|
err = e
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1976,7 +1976,7 @@ func (f *Fs) Root() string {
|
|||||||
// String converts this Fs to a string
|
// String converts this Fs to a string
|
||||||
func (f *Fs) String() string {
|
func (f *Fs) String() string {
|
||||||
if f.rootBucket == "" {
|
if f.rootBucket == "" {
|
||||||
return fmt.Sprintf("S3 root")
|
return "S3 root"
|
||||||
}
|
}
|
||||||
if f.rootDirectory == "" {
|
if f.rootDirectory == "" {
|
||||||
return fmt.Sprintf("S3 bucket %s", f.rootBucket)
|
return fmt.Sprintf("S3 bucket %s", f.rootBucket)
|
||||||
@ -2669,9 +2669,7 @@ func (f *Fs) list(ctx context.Context, bucket, directory, prefix string, addBuck
|
|||||||
if addBucket {
|
if addBucket {
|
||||||
remote = path.Join(bucket, remote)
|
remote = path.Join(bucket, remote)
|
||||||
}
|
}
|
||||||
if strings.HasSuffix(remote, "/") {
|
remote = strings.TrimSuffix(remote, "/")
|
||||||
remote = remote[:len(remote)-1]
|
|
||||||
}
|
|
||||||
err = fn(remote, &s3.Object{Key: &remote}, true)
|
err = fn(remote, &s3.Object{Key: &remote}, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -453,7 +453,7 @@ func (f *Fs) Root() string {
|
|||||||
// String converts this Fs to a string
|
// String converts this Fs to a string
|
||||||
func (f *Fs) String() string {
|
func (f *Fs) String() string {
|
||||||
if f.libraryName == "" {
|
if f.libraryName == "" {
|
||||||
return fmt.Sprintf("seafile root")
|
return "seafile root"
|
||||||
}
|
}
|
||||||
library := "library"
|
library := "library"
|
||||||
if f.encrypted {
|
if f.encrypted {
|
||||||
@ -984,9 +984,9 @@ func (f *Fs) PublicLink(ctx context.Context, remote string, expire fs.Duration,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
if shareLinks != nil && len(shareLinks) > 0 {
|
if len(shareLinks) > 0 {
|
||||||
for _, shareLink := range shareLinks {
|
for _, shareLink := range shareLinks {
|
||||||
if shareLink.IsExpired == false {
|
if !shareLink.IsExpired {
|
||||||
return shareLink.Link, nil
|
return shareLink.Link, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1053,7 +1053,7 @@ func (f *Fs) isLibraryInCache(libraryName string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
value, found := f.libraries.GetMaybe(librariesCacheKey)
|
value, found := f.libraries.GetMaybe(librariesCacheKey)
|
||||||
if found == false {
|
if !found {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
libraries := value.([]api.Library)
|
libraries := value.([]api.Library)
|
||||||
@ -1130,7 +1130,7 @@ func (f *Fs) mkLibrary(ctx context.Context, libraryName, password string) error
|
|||||||
}
|
}
|
||||||
// Stores the library details into the cache
|
// Stores the library details into the cache
|
||||||
value, found := f.libraries.GetMaybe(librariesCacheKey)
|
value, found := f.libraries.GetMaybe(librariesCacheKey)
|
||||||
if found == false {
|
if !found {
|
||||||
// Don't update the cache at that point
|
// Don't update the cache at that point
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -1077,7 +1077,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Obj
|
|||||||
}
|
}
|
||||||
dstLeaf = f.opt.Enc.FromStandardName(dstLeaf)
|
dstLeaf = f.opt.Enc.FromStandardName(dstLeaf)
|
||||||
|
|
||||||
sameName := strings.ToLower(srcLeaf) == strings.ToLower(dstLeaf)
|
sameName := strings.EqualFold(srcLeaf, dstLeaf)
|
||||||
if sameName && srcParentID == dstParentID {
|
if sameName && srcParentID == dstParentID {
|
||||||
return nil, fmt.Errorf("copy: can't copy to a file in the same directory whose name only differs in case: %q vs %q", srcLeaf, dstLeaf)
|
return nil, fmt.Errorf("copy: can't copy to a file in the same directory whose name only differs in case: %q vs %q", srcLeaf, dstLeaf)
|
||||||
}
|
}
|
||||||
@ -1096,7 +1096,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (dst fs.Obj
|
|||||||
directCopy = true
|
directCopy = true
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, fmt.Errorf("copy: failed to examine destination dir: %w", err)
|
return nil, fmt.Errorf("copy: failed to examine destination dir: %w", err)
|
||||||
} else {
|
//} else {
|
||||||
// otherwise need to copy via a temporary directory
|
// otherwise need to copy via a temporary directory
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -423,9 +423,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
if strings.HasSuffix(opt.APIURL, "/") {
|
opt.APIURL = strings.TrimSuffix(opt.APIURL, "/")
|
||||||
opt.APIURL = strings.TrimSuffix(opt.APIURL, "/")
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse the endpoint
|
// Parse the endpoint
|
||||||
u, err := url.Parse(opt.APIURL)
|
u, err := url.Parse(opt.APIURL)
|
||||||
|
@ -872,7 +872,7 @@ func (f *Fs) Copy(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
|
|
||||||
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
srcPath := srcObj.fs.rootSlash() + srcObj.remote
|
||||||
dstPath := f.rootSlash() + remote
|
dstPath := f.rootSlash() + remote
|
||||||
if strings.ToLower(srcPath) == strings.ToLower(dstPath) {
|
if strings.EqualFold(srcPath, dstPath) {
|
||||||
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
return nil, fmt.Errorf("can't copy %q -> %q as are same name when lowercase", srcPath, dstPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ func (f *Fs) Root() string {
|
|||||||
// String converts this Fs to a string
|
// String converts this Fs to a string
|
||||||
func (f *Fs) String() string {
|
func (f *Fs) String() string {
|
||||||
if f.rootContainer == "" {
|
if f.rootContainer == "" {
|
||||||
return fmt.Sprintf("Swift root")
|
return "Swift root"
|
||||||
}
|
}
|
||||||
if f.rootDirectory == "" {
|
if f.rootDirectory == "" {
|
||||||
return fmt.Sprintf("Swift container %s", f.rootContainer)
|
return fmt.Sprintf("Swift container %s", f.rootContainer)
|
||||||
@ -1271,7 +1271,7 @@ func (o *Object) getSegmentsLargeObject(ctx context.Context) (map[string][]strin
|
|||||||
if _, ok := containerSegments[segmentContainer]; !ok {
|
if _, ok := containerSegments[segmentContainer]; !ok {
|
||||||
containerSegments[segmentContainer] = make([]string, 0, len(segmentObjects))
|
containerSegments[segmentContainer] = make([]string, 0, len(segmentObjects))
|
||||||
}
|
}
|
||||||
segments, _ := containerSegments[segmentContainer]
|
segments := containerSegments[segmentContainer]
|
||||||
segments = append(segments, segment.Name)
|
segments = append(segments, segment.Name)
|
||||||
containerSegments[segmentContainer] = segments
|
containerSegments[segmentContainer] = segments
|
||||||
}
|
}
|
||||||
@ -1363,7 +1363,7 @@ func (o *Object) updateChunks(ctx context.Context, in0 io.Reader, headers swift.
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fs.Debugf(o, "Delete segments when err raise %v", err)
|
fs.Debugf(o, "Delete segments when err raise %v", err)
|
||||||
if segmentInfos == nil || len(segmentInfos) == 0 {
|
if len(segmentInfos) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_ctx := context.Background()
|
_ctx := context.Background()
|
||||||
@ -1418,7 +1418,7 @@ func (o *Object) updateChunks(ctx context.Context, in0 io.Reader, headers swift.
|
|||||||
}
|
}
|
||||||
|
|
||||||
func deleteChunks(ctx context.Context, o *Object, segmentsContainer string, segmentInfos []string) {
|
func deleteChunks(ctx context.Context, o *Object, segmentsContainer string, segmentInfos []string) {
|
||||||
if segmentInfos == nil || len(segmentInfos) == 0 {
|
if len(segmentInfos) == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, v := range segmentInfos {
|
for _, v := range segmentInfos {
|
||||||
|
@ -703,8 +703,7 @@ func (f *Fs) Move(ctx context.Context, src fs.Object, remote string) (fs.Object,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy the old object and apply the changes
|
// copy the old object and apply the changes
|
||||||
var newObj Object
|
newObj := *srcObj
|
||||||
newObj = *srcObj
|
|
||||||
newObj.remote = remote
|
newObj.remote = remote
|
||||||
newObj.fs = f
|
newObj.fs = f
|
||||||
return &newObj, nil
|
return &newObj, nil
|
||||||
@ -759,7 +758,7 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
|||||||
}
|
}
|
||||||
// check if the destination allready exists
|
// check if the destination allready exists
|
||||||
dstPath := f.dirPath(dstRemote)
|
dstPath := f.dirPath(dstRemote)
|
||||||
dstInfo, err := f.readMetaDataForPath(ctx, dstPath, &api.MetadataRequestOptions{Limit: 1})
|
_, err = f.readMetaDataForPath(ctx, dstPath, &api.MetadataRequestOptions{Limit: 1})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
return fs.ErrorDirExists
|
return fs.ErrorDirExists
|
||||||
}
|
}
|
||||||
@ -772,7 +771,7 @@ func (f *Fs) DirMove(ctx context.Context, src fs.Fs, srcRemote, dstRemote string
|
|||||||
}
|
}
|
||||||
|
|
||||||
// find the destination parent dir
|
// find the destination parent dir
|
||||||
dstInfo, err = f.readMetaDataForPath(ctx, dstBase, &api.MetadataRequestOptions{Limit: 1})
|
dstInfo, err := f.readMetaDataForPath(ctx, dstBase, &api.MetadataRequestOptions{Limit: 1})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("dirmove: failed to read destination: %w", err)
|
return fmt.Errorf("dirmove: failed to read destination: %w", err)
|
||||||
}
|
}
|
||||||
|
@ -716,9 +716,7 @@ func (f *Fs) listAll(ctx context.Context, dir string, directoriesOnly bool, file
|
|||||||
subPath = f.opt.Enc.ToStandardPath(subPath)
|
subPath = f.opt.Enc.ToStandardPath(subPath)
|
||||||
}
|
}
|
||||||
remote := path.Join(dir, subPath)
|
remote := path.Join(dir, subPath)
|
||||||
if strings.HasSuffix(remote, "/") {
|
remote = strings.TrimSuffix(remote, "/")
|
||||||
remote = remote[:len(remote)-1]
|
|
||||||
}
|
|
||||||
|
|
||||||
// the listing contains info about itself which we ignore
|
// the listing contains info about itself which we ignore
|
||||||
if remote == dir {
|
if remote == dir {
|
||||||
@ -820,10 +818,7 @@ func (f *Fs) PutStream(ctx context.Context, in io.Reader, src fs.ObjectInfo, opt
|
|||||||
func (f *Fs) mkParentDir(ctx context.Context, dirPath string) (err error) {
|
func (f *Fs) mkParentDir(ctx context.Context, dirPath string) (err error) {
|
||||||
// defer log.Trace(dirPath, "")("err=%v", &err)
|
// defer log.Trace(dirPath, "")("err=%v", &err)
|
||||||
// chop off trailing / if it exists
|
// chop off trailing / if it exists
|
||||||
if strings.HasSuffix(dirPath, "/") {
|
parent := path.Dir(strings.TrimSuffix(dirPath, "/"))
|
||||||
dirPath = dirPath[:len(dirPath)-1]
|
|
||||||
}
|
|
||||||
parent := path.Dir(dirPath)
|
|
||||||
if parent == "." {
|
if parent == "." {
|
||||||
parent = ""
|
parent = ""
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ func (m *SortMode) String() string {
|
|||||||
|
|
||||||
// UnmarshalJSON sort mode
|
// UnmarshalJSON sort mode
|
||||||
func (m *SortMode) UnmarshalJSON(value []byte) error {
|
func (m *SortMode) UnmarshalJSON(value []byte) error {
|
||||||
if value == nil || len(value) == 0 {
|
if len(value) == 0 {
|
||||||
m.mode = ""
|
m.mode = ""
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -468,7 +468,7 @@ func (f *Fs) CreateDir(ctx context.Context, path string) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If creating a directory with a : use (undocumented) disk: prefix
|
// If creating a directory with a : use (undocumented) disk: prefix
|
||||||
if strings.IndexRune(path, ':') >= 0 {
|
if strings.ContainsRune(path, ':') {
|
||||||
path = "disk:" + path
|
path = "disk:" + path
|
||||||
}
|
}
|
||||||
opts.Parameters.Set("path", f.opt.Enc.FromStandardPath(path))
|
opts.Parameters.Set("path", f.opt.Enc.FromStandardPath(path))
|
||||||
@ -506,10 +506,8 @@ func (f *Fs) mkDirs(ctx context.Context, path string) (err error) {
|
|||||||
var mkdirpath = "/" //path separator /
|
var mkdirpath = "/" //path separator /
|
||||||
for _, element := range dirs {
|
for _, element := range dirs {
|
||||||
if element != "" {
|
if element != "" {
|
||||||
mkdirpath += element + "/" //path separator /
|
mkdirpath += element + "/" //path separator /
|
||||||
if err = f.CreateDir(ctx, mkdirpath); err != nil {
|
_ = f.CreateDir(ctx, mkdirpath) // ignore errors while creating dirs
|
||||||
// ignore errors while creating dirs
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -522,10 +520,7 @@ func (f *Fs) mkDirs(ctx context.Context, path string) (err error) {
|
|||||||
func (f *Fs) mkParentDirs(ctx context.Context, resPath string) error {
|
func (f *Fs) mkParentDirs(ctx context.Context, resPath string) error {
|
||||||
// defer log.Trace(dirPath, "")("")
|
// defer log.Trace(dirPath, "")("")
|
||||||
// chop off trailing / if it exists
|
// chop off trailing / if it exists
|
||||||
if strings.HasSuffix(resPath, "/") {
|
parent := path.Dir(strings.TrimSuffix(resPath, "/"))
|
||||||
resPath = resPath[:len(resPath)-1]
|
|
||||||
}
|
|
||||||
parent := path.Dir(resPath)
|
|
||||||
if parent == "." {
|
if parent == "." {
|
||||||
parent = ""
|
parent = ""
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ func shouldRetry(ctx context.Context, resp *http.Response, err error) (bool, err
|
|||||||
}
|
}
|
||||||
authRetry := false
|
authRetry := false
|
||||||
|
|
||||||
if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Index(resp.Header["Www-Authenticate"][0], "expired_token") >= 0 {
|
if resp != nil && resp.StatusCode == 401 && len(resp.Header["Www-Authenticate"]) == 1 && strings.Contains(resp.Header["Www-Authenticate"][0], "expired_token") {
|
||||||
authRetry = true
|
authRetry = true
|
||||||
fs.Debugf(nil, "Should retry: %v", err)
|
fs.Debugf(nil, "Should retry: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -273,7 +273,7 @@ func Run(Retry bool, showStats bool, cmd *cobra.Command, f func() error) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
if retryAfter := accounting.GlobalStats().RetryAfter(); !retryAfter.IsZero() {
|
if retryAfter := accounting.GlobalStats().RetryAfter(); !retryAfter.IsZero() {
|
||||||
d := retryAfter.Sub(time.Now())
|
d := time.Until(retryAfter)
|
||||||
if d > 0 {
|
if d > 0 {
|
||||||
fs.Logf(nil, "Received retry after error - sleeping until %s (%v)", retryAfter.Format(time.RFC3339Nano), d)
|
fs.Logf(nil, "Received retry after error - sleeping until %s (%v)", retryAfter.Format(time.RFC3339Nano), d)
|
||||||
time.Sleep(d)
|
time.Sleep(d)
|
||||||
@ -458,7 +458,7 @@ func initConfig() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if m, _ := regexp.MatchString("^(bits|bytes)$", *dataRateUnit); m == false {
|
if m, _ := regexp.MatchString("^(bits|bytes)$", *dataRateUnit); !m {
|
||||||
fs.Errorf(nil, "Invalid unit passed to --stats-unit. Defaulting to bytes.")
|
fs.Errorf(nil, "Invalid unit passed to --stats-unit. Defaulting to bytes.")
|
||||||
ci.DataRateUnit = "bytes"
|
ci.DataRateUnit = "bytes"
|
||||||
} else {
|
} else {
|
||||||
|
@ -75,7 +75,7 @@ func cryptDecode(cipher *crypt.Cipher, args []string) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(output)
|
fmt.Print(output)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ func cryptEncode(cipher *crypt.Cipher, args []string) error {
|
|||||||
output += fmt.Sprintln(fileName, "\t", encryptedFileName)
|
output += fmt.Sprintln(fileName, "\t", encryptedFileName)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf(output)
|
fmt.Print(output)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -200,9 +200,7 @@ func InstallUpdate(ctx context.Context, opt *Options) error {
|
|||||||
savedFile := ""
|
savedFile := ""
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
savedFile = targetFile
|
savedFile = targetFile
|
||||||
if strings.HasSuffix(savedFile, ".exe") {
|
savedFile = strings.TrimSuffix(savedFile, ".exe")
|
||||||
savedFile = savedFile[:len(savedFile)-4]
|
|
||||||
}
|
|
||||||
savedFile += ".old.exe"
|
savedFile += ".old.exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,9 +317,7 @@ func makeRandomExeName(baseName, extension string) (string, error) {
|
|||||||
const maxAttempts = 5
|
const maxAttempts = 5
|
||||||
|
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
if strings.HasSuffix(baseName, ".exe") {
|
baseName = strings.TrimSuffix(baseName, ".exe")
|
||||||
baseName = baseName[:len(baseName)-4]
|
|
||||||
}
|
|
||||||
extension += ".exe"
|
extension += ".exe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ var (
|
|||||||
pluginName = "rclone"
|
pluginName = "rclone"
|
||||||
pluginScope = "local"
|
pluginScope = "local"
|
||||||
baseDir = "/var/lib/docker-volumes/rclone"
|
baseDir = "/var/lib/docker-volumes/rclone"
|
||||||
sockDir = "/run/docker/plugins"
|
sockDir = "/run/docker/plugins" // location of unix sockets (only relevant on Linux and FreeBSD)
|
||||||
defSpecDir = "/etc/docker/plugins"
|
defSpecDir = "/etc/docker/plugins"
|
||||||
stateFile = "docker-plugin.state"
|
stateFile = "docker-plugin.state"
|
||||||
socketAddr = "" // TCP listening address or empty string for Unix socket
|
socketAddr = "" // TCP listening address or empty string for Unix socket
|
||||||
|
@ -156,11 +156,11 @@ func (p *Proxy) run(in map[string]string) (config configmap.Simple, err error) {
|
|||||||
fs.Debugf(nil, "Calling proxy %v", p.cmdLine)
|
fs.Debugf(nil, "Calling proxy %v", p.cmdLine)
|
||||||
duration := time.Since(start)
|
duration := time.Since(start)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("proxy: failed on %v: %q: %w", p.cmdLine, strings.TrimSpace(string(stderr.Bytes())), err)
|
return nil, fmt.Errorf("proxy: failed on %v: %q: %w", p.cmdLine, strings.TrimSpace(stderr.String()), err)
|
||||||
}
|
}
|
||||||
err = json.Unmarshal(stdout.Bytes(), &config)
|
err = json.Unmarshal(stdout.Bytes(), &config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("proxy: failed to read output: %q: %w", string(stdout.Bytes()), err)
|
return nil, fmt.Errorf("proxy: failed to read output: %q: %w", stdout.String(), err)
|
||||||
}
|
}
|
||||||
fs.Debugf(nil, "Proxy returned in %v", duration)
|
fs.Debugf(nil, "Proxy returned in %v", duration)
|
||||||
|
|
||||||
|
@ -254,7 +254,6 @@ func (d *dir) createDirectories() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// list the directory hierarchy
|
// list the directory hierarchy
|
||||||
|
@ -444,7 +444,7 @@ func (acc *Account) speed() (bps, current float64) {
|
|||||||
return 0, 0
|
return 0, 0
|
||||||
}
|
}
|
||||||
// Calculate speed from first read.
|
// Calculate speed from first read.
|
||||||
total := float64(time.Now().Sub(acc.values.start)) / float64(time.Second)
|
total := float64(time.Since(acc.values.start)) / float64(time.Second)
|
||||||
if total > 0 {
|
if total > 0 {
|
||||||
bps = float64(acc.values.bytes) / total
|
bps = float64(acc.values.bytes) / total
|
||||||
} else {
|
} else {
|
||||||
|
@ -111,9 +111,9 @@ func TestStatsGroupOperations(t *testing.T) {
|
|||||||
runtime.GC()
|
runtime.GC()
|
||||||
runtime.ReadMemStats(&end)
|
runtime.ReadMemStats(&end)
|
||||||
|
|
||||||
t.Log(fmt.Sprintf("%+v\n%+v", start, end))
|
t.Logf("%+v\n%+v", start, end)
|
||||||
diff := percentDiff(start.HeapObjects, end.HeapObjects)
|
diff := percentDiff(start.HeapObjects, end.HeapObjects)
|
||||||
if diff > 1 || diff < 0 {
|
if diff > 1 {
|
||||||
t.Errorf("HeapObjects = %d, expected %d", end.HeapObjects, start.HeapObjects)
|
t.Errorf("HeapObjects = %d, expected %d", end.HeapObjects, start.HeapObjects)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -68,8 +68,8 @@ func (a *AsyncReader) init(rd io.ReadCloser, buffers int) {
|
|||||||
a.in = rd
|
a.in = rd
|
||||||
a.ready = make(chan *buffer, buffers)
|
a.ready = make(chan *buffer, buffers)
|
||||||
a.token = make(chan struct{}, buffers)
|
a.token = make(chan struct{}, buffers)
|
||||||
a.exit = make(chan struct{}, 0)
|
a.exit = make(chan struct{})
|
||||||
a.exited = make(chan struct{}, 0)
|
a.exited = make(chan struct{})
|
||||||
a.buffers = buffers
|
a.buffers = buffers
|
||||||
a.cur = nil
|
a.cur = nil
|
||||||
a.size = softStartInitial
|
a.size = softStartInitial
|
||||||
|
@ -187,10 +187,7 @@ func (s *Storage) Serialize() (string, error) {
|
|||||||
func (s *Storage) HasSection(section string) bool {
|
func (s *Storage) HasSection(section string) bool {
|
||||||
s.check()
|
s.check()
|
||||||
_, err := s.gc.GetSection(section)
|
_, err := s.gc.GetSection(section)
|
||||||
if err != nil {
|
return err == nil
|
||||||
return false
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteSection removes the named section and all config from the
|
// DeleteSection removes the named section and all config from the
|
||||||
|
@ -72,10 +72,7 @@ See the [listremotes command](/commands/rclone_listremotes/) command for more in
|
|||||||
|
|
||||||
// Return the a list of remotes in the config file
|
// Return the a list of remotes in the config file
|
||||||
func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
func rcListRemotes(ctx context.Context, in rc.Params) (out rc.Params, err error) {
|
||||||
var remotes = []string{}
|
remotes := LoadedData().GetSectionList()
|
||||||
for _, remote := range LoadedData().GetSectionList() {
|
|
||||||
remotes = append(remotes, remote)
|
|
||||||
}
|
|
||||||
out = rc.Params{
|
out = rc.Params{
|
||||||
"remotes": remotes,
|
"remotes": remotes,
|
||||||
}
|
}
|
||||||
|
@ -596,7 +596,7 @@ func (f *Filter) UsesDirectoryFilters() bool {
|
|||||||
}
|
}
|
||||||
rule := f.dirRules.rules[0]
|
rule := f.dirRules.rules[0]
|
||||||
re := rule.Regexp.String()
|
re := rule.Regexp.String()
|
||||||
if rule.Include == true && re == "^.*$" {
|
if rule.Include && re == "^.*$" {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
@ -258,7 +258,7 @@ func NewErrorRetryAfter(d time.Duration) ErrorRetryAfter {
|
|||||||
|
|
||||||
// Error returns the textual version of the error
|
// Error returns the textual version of the error
|
||||||
func (e ErrorRetryAfter) Error() string {
|
func (e ErrorRetryAfter) Error() string {
|
||||||
return fmt.Sprintf("try again after %v (%v)", time.Time(e).Format(time.RFC3339Nano), time.Time(e).Sub(time.Now()))
|
return fmt.Sprintf("try again after %v (%v)", time.Time(e).Format(time.RFC3339Nano), time.Until(time.Time(e)))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RetryAfter returns the time the operation should be retried at or
|
// RetryAfter returns the time the operation should be retried at or
|
||||||
|
@ -181,7 +181,7 @@ func TestShouldRetry(t *testing.T) {
|
|||||||
func TestRetryAfter(t *testing.T) {
|
func TestRetryAfter(t *testing.T) {
|
||||||
e := NewErrorRetryAfter(time.Second)
|
e := NewErrorRetryAfter(time.Second)
|
||||||
after := e.RetryAfter()
|
after := e.RetryAfter()
|
||||||
dt := after.Sub(time.Now())
|
dt := time.Until(after)
|
||||||
assert.True(t, dt >= 900*time.Millisecond && dt <= 1100*time.Millisecond)
|
assert.True(t, dt >= 900*time.Millisecond && dt <= 1100*time.Millisecond)
|
||||||
assert.True(t, IsRetryAfterError(e))
|
assert.True(t, IsRetryAfterError(e))
|
||||||
assert.False(t, IsRetryAfterError(io.EOF))
|
assert.False(t, IsRetryAfterError(io.EOF))
|
||||||
|
@ -99,7 +99,7 @@ func Parse(path string) (parsed Parsed, err error) {
|
|||||||
return parsed, errCantBeEmpty
|
return parsed, errCantBeEmpty
|
||||||
}
|
}
|
||||||
// If path has no `:` in, it must be a local path
|
// If path has no `:` in, it must be a local path
|
||||||
if strings.IndexRune(path, ':') < 0 {
|
if !strings.ContainsRune(path, ':') {
|
||||||
return parsed, nil
|
return parsed, nil
|
||||||
}
|
}
|
||||||
// States for parser
|
// States for parser
|
||||||
|
@ -45,7 +45,7 @@ func findCaller(skip int) string {
|
|||||||
line := 0
|
line := 0
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
file, line = getCaller(skip + i)
|
file, line = getCaller(skip + i)
|
||||||
if !strings.HasPrefix(file, "logrus") && strings.Index(file, "log.go") < 0 {
|
if !strings.HasPrefix(file, "logrus") && !strings.Contains(file, "log.go") {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ func ParseRangeOption(s string) (po *RangeOption, err error) {
|
|||||||
return nil, errors.New("Range: header invalid: doesn't start with " + preamble)
|
return nil, errors.New("Range: header invalid: doesn't start with " + preamble)
|
||||||
}
|
}
|
||||||
s = s[len(preamble):]
|
s = s[len(preamble):]
|
||||||
if strings.IndexRune(s, ',') >= 0 {
|
if strings.ContainsRune(s, ',') {
|
||||||
return nil, errors.New("Range: header invalid: contains multiple ranges which isn't supported")
|
return nil, errors.New("Range: header invalid: contains multiple ranges which isn't supported")
|
||||||
}
|
}
|
||||||
dash := strings.IndexRune(s, '-')
|
dash := strings.IndexRune(s, '-')
|
||||||
@ -250,7 +250,7 @@ func (o NullOption) Header() (key string, value string) {
|
|||||||
|
|
||||||
// String formats the option into human-readable form
|
// String formats the option into human-readable form
|
||||||
func (o NullOption) String() string {
|
func (o NullOption) String() string {
|
||||||
return fmt.Sprintf("NullOption()")
|
return "NullOption()"
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mandatory returns whether the option must be parsed or can be ignored
|
// Mandatory returns whether the option must be parsed or can be ignored
|
||||||
|
@ -378,7 +378,7 @@ func (s *Server) handleGet(w http.ResponseWriter, r *http.Request, path string)
|
|||||||
if s.opt.WebUI {
|
if s.opt.WebUI {
|
||||||
pluginsMatchResult := webgui.PluginsMatch.FindStringSubmatch(path)
|
pluginsMatchResult := webgui.PluginsMatch.FindStringSubmatch(path)
|
||||||
|
|
||||||
if pluginsMatchResult != nil && len(pluginsMatchResult) > 2 {
|
if len(pluginsMatchResult) > 2 {
|
||||||
ok := webgui.ServePluginOK(w, r, pluginsMatchResult)
|
ok := webgui.ServePluginOK(w, r, pluginsMatchResult)
|
||||||
if !ok {
|
if !ok {
|
||||||
r.URL.Path = fmt.Sprintf("/%s/%s/app/build/%s", pluginsMatchResult[1], pluginsMatchResult[2], pluginsMatchResult[3])
|
r.URL.Path = fmt.Sprintf("/%s/%s/app/build/%s", pluginsMatchResult[1], pluginsMatchResult[2], pluginsMatchResult[3])
|
||||||
|
@ -293,7 +293,7 @@ func ServePluginOK(w http.ResponseWriter, r *http.Request, pluginsMatchResult []
|
|||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
var referrerPathReg = regexp.MustCompile("^(https?):\\/\\/(.+):([0-9]+)?\\/(.*)\\/?\\?(.*)$")
|
var referrerPathReg = regexp.MustCompile(`^(https?):\/\/(.+):([0-9]+)?\/(.*)\/?\?(.*)$`)
|
||||||
|
|
||||||
// ServePluginWithReferrerOK check if redirectReferrer is set for the referred a plugin, if yes,
|
// ServePluginWithReferrerOK check if redirectReferrer is set for the referred a plugin, if yes,
|
||||||
// sends a redirect to actual url. This function is useful for plugins to refer to absolute paths when
|
// sends a redirect to actual url. This function is useful for plugins to refer to absolute paths when
|
||||||
@ -306,9 +306,9 @@ func ServePluginWithReferrerOK(w http.ResponseWriter, r *http.Request, path stri
|
|||||||
referrer := r.Referer()
|
referrer := r.Referer()
|
||||||
referrerPathMatch := referrerPathReg.FindStringSubmatch(referrer)
|
referrerPathMatch := referrerPathReg.FindStringSubmatch(referrer)
|
||||||
|
|
||||||
if referrerPathMatch != nil && len(referrerPathMatch) > 3 {
|
if len(referrerPathMatch) > 3 {
|
||||||
referrerPluginMatch := PluginsMatch.FindStringSubmatch(referrerPathMatch[4])
|
referrerPluginMatch := PluginsMatch.FindStringSubmatch(referrerPathMatch[4])
|
||||||
if referrerPluginMatch != nil && len(referrerPluginMatch) > 2 {
|
if len(referrerPluginMatch) > 2 {
|
||||||
pluginKey := fmt.Sprintf("%s/%s", referrerPluginMatch[1], referrerPluginMatch[2])
|
pluginKey := fmt.Sprintf("%s/%s", referrerPluginMatch[1], referrerPluginMatch[2])
|
||||||
currentPlugin, err := loadedPlugins.GetPluginByName(pluginKey)
|
currentPlugin, err := loadedPlugins.GetPluginByName(pluginKey)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -387,8 +387,7 @@ func Run(t *testing.T, opt *Opt) {
|
|||||||
// Skip if remote is not SetTier and GetTier capable
|
// Skip if remote is not SetTier and GetTier capable
|
||||||
skipIfNotSetTier := func(t *testing.T) {
|
skipIfNotSetTier := func(t *testing.T) {
|
||||||
skipIfNotOk(t)
|
skipIfNotOk(t)
|
||||||
if f.Features().SetTier == false ||
|
if !f.Features().SetTier || !f.Features().GetTier {
|
||||||
f.Features().GetTier == false {
|
|
||||||
t.Skip("FS has no SetTier & GetTier interfaces")
|
t.Skip("FS has no SetTier & GetTier interfaces")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -735,7 +734,7 @@ func Run(t *testing.T, opt *Opt) {
|
|||||||
|
|
||||||
TestPutLarge(ctx, t, f, &fstest.Item{
|
TestPutLarge(ctx, t, f, &fstest.Item{
|
||||||
ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"),
|
ModTime: fstest.Time("2001-02-03T04:05:06.499999999Z"),
|
||||||
Path: fmt.Sprintf("zero-length-file"),
|
Path: "zero-length-file",
|
||||||
Size: int64(0),
|
Size: int64(0),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -465,17 +465,13 @@ func getMapping(mask encoder.MultiEncoder) mapping {
|
|||||||
}
|
}
|
||||||
func collectEncodables(m []mapping) (out []rune) {
|
func collectEncodables(m []mapping) (out []rune) {
|
||||||
for _, s := range m {
|
for _, s := range m {
|
||||||
for _, r := range s.src {
|
out = append(out, s.src...)
|
||||||
out = append(out, r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
func collectEncoded(m []mapping) (out []rune) {
|
func collectEncoded(m []mapping) (out []rune) {
|
||||||
for _, s := range m {
|
for _, s := range m {
|
||||||
for _, r := range s.dst {
|
out = append(out, s.dst...)
|
||||||
out = append(out, r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ func TestKvConcurrency(t *testing.T) {
|
|||||||
require.Equal(t, 0, len(dbMap), "no databases can be started initially")
|
require.Equal(t, 0, len(dbMap), "no databases can be started initially")
|
||||||
|
|
||||||
const threadNum = 5
|
const threadNum = 5
|
||||||
const facility = "test"
|
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
results := make([]*DB, threadNum)
|
results := make([]*DB, threadNum)
|
||||||
@ -55,7 +54,6 @@ func TestKvConcurrency(t *testing.T) {
|
|||||||
func TestKvExit(t *testing.T) {
|
func TestKvExit(t *testing.T) {
|
||||||
require.Equal(t, 0, len(dbMap), "no databases can be started initially")
|
require.Equal(t, 0, len(dbMap), "no databases can be started initially")
|
||||||
const dbNum = 5
|
const dbNum = 5
|
||||||
const openNum = 2
|
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
for i := 0; i < dbNum; i++ {
|
for i := 0; i < dbNum; i++ {
|
||||||
facility := fmt.Sprintf("test-%d", i)
|
facility := fmt.Sprintf("test-%d", i)
|
||||||
|
@ -280,7 +280,7 @@ func (ts *TokenSource) timeToExpiry() time.Duration {
|
|||||||
if t.Expiry.IsZero() {
|
if t.Expiry.IsZero() {
|
||||||
return 3e9 * time.Second // ~95 years
|
return 3e9 * time.Second // ~95 years
|
||||||
}
|
}
|
||||||
return t.Expiry.Sub(time.Now())
|
return time.Until(t.Expiry)
|
||||||
}
|
}
|
||||||
|
|
||||||
// OnExpiry returns a channel which has the time written to it when
|
// OnExpiry returns a channel which has the time written to it when
|
||||||
@ -766,7 +766,6 @@ func (s *authServer) Init() error {
|
|||||||
}
|
}
|
||||||
fs.Debugf(nil, "Redirecting browser to: %s", s.authURL)
|
fs.Debugf(nil, "Redirecting browser to: %s", s.authURL)
|
||||||
http.Redirect(w, req, s.authURL, http.StatusTemporaryRedirect)
|
http.Redirect(w, req, s.authURL, http.StatusTemporaryRedirect)
|
||||||
return
|
|
||||||
})
|
})
|
||||||
mux.HandleFunc("/", s.handleAuth)
|
mux.HandleFunc("/", s.handleAuth)
|
||||||
|
|
||||||
|
@ -22,7 +22,6 @@ func NewTokenDispenser(n int) *TokenDispenser {
|
|||||||
// Get gets a token from the pool - don't forget to return it with Put
|
// Get gets a token from the pool - don't forget to return it with Put
|
||||||
func (td *TokenDispenser) Get() {
|
func (td *TokenDispenser) Get() {
|
||||||
<-td.tokens
|
<-td.tokens
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put returns a token
|
// Put returns a token
|
||||||
|
@ -11,7 +11,7 @@ import (
|
|||||||
|
|
||||||
const versionFormat = "-v2006-01-02-150405.000"
|
const versionFormat = "-v2006-01-02-150405.000"
|
||||||
|
|
||||||
var versionRegexp = regexp.MustCompile("-v\\d{4}-\\d{2}-\\d{2}-\\d{6}-\\d{3}")
|
var versionRegexp = regexp.MustCompile(`-v\d{4}-\d{2}-\d{2}-\d{6}-\d{3}`)
|
||||||
|
|
||||||
// Split fileName into base and extension so that base + ext == fileName
|
// Split fileName into base and extension so that base + ext == fileName
|
||||||
func splitExt(fileName string) (base, ext string) {
|
func splitExt(fileName string) (base, ext string) {
|
||||||
|
@ -506,7 +506,7 @@ func (d *Dir) _purgeVirtual() {
|
|||||||
// if remote can have empty directories then a
|
// if remote can have empty directories then a
|
||||||
// new dir will be read in the listing
|
// new dir will be read in the listing
|
||||||
d._deleteVirtual(name)
|
d._deleteVirtual(name)
|
||||||
} else {
|
//} else {
|
||||||
// leave the empty directory marker
|
// leave the empty directory marker
|
||||||
}
|
}
|
||||||
case vAddFile:
|
case vAddFile:
|
||||||
|
@ -477,7 +477,7 @@ func (fh *ReadFileHandle) Release() error {
|
|||||||
err := fh.close()
|
err := fh.close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Errorf(fh.remote, "ReadFileHandle.Release error: %v", err)
|
fs.Errorf(fh.remote, "ReadFileHandle.Release error: %v", err)
|
||||||
} else {
|
//} else {
|
||||||
// fs.Debugf(fh.remote, "ReadFileHandle.Release OK")
|
// fs.Debugf(fh.remote, "ReadFileHandle.Release OK")
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -359,7 +359,7 @@ func (dls *Downloaders) _ensureDownloader(r ranges.Range) (err error) {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Downloader not found so start a new one
|
// Downloader not found so start a new one
|
||||||
dl, err = dls._newDownloader(r)
|
_, err = dls._newDownloader(r)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
dls._countErrors(0, err)
|
dls._countErrors(0, err)
|
||||||
return fmt.Errorf("failed to start downloader: %w", err)
|
return fmt.Errorf("failed to start downloader: %w", err)
|
||||||
|
@ -779,7 +779,7 @@ func (item *Item) _checkObject(o fs.Object) error {
|
|||||||
} else {
|
} else {
|
||||||
fs.Debugf(item.name, "vfs cache: remote object has gone but local object modified - keeping it")
|
fs.Debugf(item.name, "vfs cache: remote object has gone but local object modified - keeping it")
|
||||||
}
|
}
|
||||||
} else {
|
//} else {
|
||||||
// no remote object && no local object
|
// no remote object && no local object
|
||||||
// OK
|
// OK
|
||||||
}
|
}
|
||||||
@ -946,7 +946,7 @@ func (item *Item) Reset() (rr ResetResult, spaceFreed int64, err error) {
|
|||||||
|
|
||||||
/* Do not need to reset an empty cache file unless it was being reset and the reset failed.
|
/* Do not need to reset an empty cache file unless it was being reset and the reset failed.
|
||||||
Some thread(s) may be waiting on the reset's succesful completion in that case. */
|
Some thread(s) may be waiting on the reset's succesful completion in that case. */
|
||||||
if item.info.Rs.Size() == 0 && item.beingReset == false {
|
if item.info.Rs.Size() == 0 && !item.beingReset {
|
||||||
return SkippedEmpty, 0, nil
|
return SkippedEmpty, 0, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,7 @@ func TestWriteFileDoubleClose(t *testing.T) {
|
|||||||
|
|
||||||
// writeTestDup performs the platform-specific implementation of the dup() syscall
|
// writeTestDup performs the platform-specific implementation of the dup() syscall
|
||||||
func writeTestDup(oldfd uintptr) (uintptr, error) {
|
func writeTestDup(oldfd uintptr) (uintptr, error) {
|
||||||
p, err := windows.GetCurrentProcess()
|
p := windows.CurrentProcess()
|
||||||
if err != nil {
|
|
||||||
return 0, err
|
|
||||||
}
|
|
||||||
var h windows.Handle
|
var h windows.Handle
|
||||||
return uintptr(h), windows.DuplicateHandle(p, windows.Handle(oldfd), p, &h, 0, true, windows.DUPLICATE_SAME_ACCESS)
|
return uintptr(h), windows.DuplicateHandle(p, windows.Handle(oldfd), p, &h, 0, true, windows.DUPLICATE_SAME_ACCESS)
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ func (fh *WriteFileHandle) Flush() error {
|
|||||||
err := fh.close()
|
err := fh.close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Errorf(fh.remote, "WriteFileHandle.Flush error: %v", err)
|
fs.Errorf(fh.remote, "WriteFileHandle.Flush error: %v", err)
|
||||||
} else {
|
//} else {
|
||||||
// fs.Debugf(fh.remote, "WriteFileHandle.Flush OK")
|
// fs.Debugf(fh.remote, "WriteFileHandle.Flush OK")
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
@ -268,7 +268,7 @@ func (fh *WriteFileHandle) Release() error {
|
|||||||
err := fh.close()
|
err := fh.close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fs.Errorf(fh.remote, "WriteFileHandle.Release error: %v", err)
|
fs.Errorf(fh.remote, "WriteFileHandle.Release error: %v", err)
|
||||||
} else {
|
//} else {
|
||||||
// fs.Debugf(fh.remote, "WriteFileHandle.Release OK")
|
// fs.Debugf(fh.remote, "WriteFileHandle.Release OK")
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
Loading…
Reference in New Issue
Block a user