Rclone rc operations/list question

What is the problem you are having with rclone?

I don't have a problem just an usage question about 'rclone rc operations/list'. According to the documentation its required parameters are:

  • fs - a remote name string e.g. "drive:" (or a path if its a local directory, which is not mentioned on the documentation, also while testing I noticed remote directories include links in the list, local directories do not)
  • remote - a path within that remote e.g. "dir"

So I have a smb config called SOURCE, so this works:

rclone rc operations/list fs=SOURCE: remote=/path/to/dir

But this also works

rclone rc operations/list fs=SOURCE:/path/to/dir remote=

So why is the "remote" parameter needed/used for? The "fs" only seems cleaner so what am I missing?

Also, this works:

rclone rc operations/list fs=SOURCE:/ remote=

But this does not:

rclone rc operations/list fs=SOURCE: remote=/

Run the command 'rclone version' and share the full output of the command.

Not important

Which cloud storage system are you using? (eg Google Drive)

Not important

The command you were trying to run (eg rclone copy /tmp remote:tmp)

Not important

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

Not important

A log from the command that you were trying to run with the -vv flag

Not important

Due to the way rclone works, whenever you use a different fs it instantiates a new backend for it. These are cached by the rc.

So for max efficiency use a fixed fs=SOURCE: and vary the remote=

In general rclone doesn't need the slashes, so just leave them out. So this

rclone rc operations/list fs=SOURCE: remote=

Should work fine.

What is happening is that rclone rc operations/list fs=SOURCE:/ remote= is being simplified to rclone rc operations/list fs=SOURCE: remote= but rclone rc operations/list fs=SOURCE: remote=/ is trying to list a directory called / which doesn't exist. That is my guess anyway!

What is happening is that rclone rc operations/list fs=SOURCE:/ remote= is being simplified to rclone rc operations/list fs=SOURCE: remote= but rclone rc operations/list fs=SOURCE: remote=/ is trying to list a directory called / which doesn't exist. That is my guess anyway!

The weird thing is that it is actually working, is just ignoring the files for some reason. This is the output if the command:

root@vm-test:/docker/server-backup# rclone rc operations/list fs=SOURCE: remote=/
2023/09/22 10:59:24 ERROR : storage: Entry doesn't belong in directory "/" (too short) - ignoring
2023/09/22 10:59:24 ERROR : docker: Entry doesn't belong in directory "/" (too short) - ignoring
2023/09/22 10:59:24 ERROR : system: Entry doesn't belong in directory "/" (too short) - ignoring
2023/09/22 10:59:24 ERROR : msimdisk: Entry doesn't belong in directory "/" (too short) - ignoring
2023/09/22 10:59:24 ERROR : stuff: Entry doesn't belong in directory "/" (too short) - ignoring

Since I already have the code I looked at it, in rclone/fs/list/list.go where it says

if dir != "" {
	prefix = dir + "/"
}

Change to:

// remove leading slash
dir = strings.TrimPrefix(dir, "/")
//
if dir != "" {
	prefix = dir + "/"
}

Now "rclone rc operations/list fs=SOURCE:/ remote=" and "rclone rc operations/list fs=SOURCE: remote=/" work the same. If you want extra safety use:

// remove leading slashes
dir=strings.TrimLeftFunc(dir, func(r rune) bool {
	return r=='/'
})
//
if dir != "" {
	prefix = dir + "/"
}

so now even "rclone rc operations/list fs=SOURCE: remote=////////" should work, after all we users do stupid things sometimes.

This will break stuff!

Some remotes (eg dropbox and sftp) are sensitive to a leading /. For example sftp:dir finds dir in your home directory whereas sftp:/dir finds it at the root.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.