Skip to content

Rclone requires ‛ before / even with --local-encoding None #5298

Open

Description

What is the problem you are having with rclone?

Rclone requires ‛ before / even with --local-encoding None, but not with other full width characters like ?.

What is your rclone version (output from rclone version)

rclone v1.55.1
- os/type: linux
- os/arch: amd64
- go/version: go1.16.3
- go/linking: static
- go/tags: none

Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Ubuntu 20 64 bit

Which cloud storage system are you using? (e.g. Google Drive)

local, google drive

The command you were trying to run (e.g. rclone copy /tmp remote:tmp)

rclone copy --local-encoding None 'a/b' gdrive:

A log from the command with the -vv flag (e.g. output from rclone -vv copy /tmp remote:tmp)

uu@hh /tmp/tmp.nIO15081l8 % rclone copy --local-encoding None -vv 'a/b' gdrive:
2021/05/02 14:39:58 DEBUG : Using config file from "/home/uu/.config/rclone/rclone.conf"
2021/05/02 14:39:58 DEBUG : rclone: Version "v1.55.1" starting with parameters ["rclone" "copy" "--local-encoding" "None" "-vv" "a/b" "gdrive:"]
2021/05/02 14:39:58 DEBUG : Creating backend with remote "a/b"
2021/05/02 14:39:58 DEBUG : local: detected overridden config - adding "{sb0+v}" suffix to name
2021/05/02 14:39:58 DEBUG : fs cache: renaming cache item "a/b" to be canonical "local{sb0+v}:/tmp/tmp.nIO15081l8/a/b"
2021/05/02 14:39:58 DEBUG : Creating backend with remote "gdrive:"
2021/05/02 14:39:58 ERROR : : error reading source directory: directory not found
2021/05/02 14:39:58 DEBUG : Google drive root '': Waiting for checks to finish
2021/05/02 14:39:58 DEBUG : Google drive root '': Waiting for transfers to finish
2021/05/02 14:39:58 ERROR : Attempt 1/3 failed with 1 errors and: directory not found
2021/05/02 14:39:59 ERROR : : error reading source directory: directory not found
2021/05/02 14:39:59 DEBUG : Google drive root '': Waiting for checks to finish
2021/05/02 14:39:59 DEBUG : Google drive root '': Waiting for transfers to finish
2021/05/02 14:39:59 ERROR : Attempt 2/3 failed with 1 errors and: directory not found
2021/05/02 14:39:59 ERROR : : error reading source directory: directory not found
2021/05/02 14:39:59 DEBUG : Google drive root '': Waiting for checks to finish
2021/05/02 14:39:59 DEBUG : Google drive root '': Waiting for transfers to finish
2021/05/02 14:39:59 ERROR : Attempt 3/3 failed with 1 errors and: directory not found
2021/05/02 14:39:59 INFO  :
Transferred:             0 / 0 Bytes, -, 0 Bytes/s, ETA -
Errors:                 1 (retrying may help)
Elapsed time:         0.6s

2021/05/02 14:39:59 DEBUG : 5 go routines active
2021/05/02 14:39:59 Failed to copy: directory not found

Works normally after adding ‛.

uu@hh /tmp/tmp.nIO15081l8 % rclone copy --local-encoding None -vv 'a‛/b' gdrive:
2021/05/02 14:40:13 DEBUG : Using config file from "/home/uu/.config/rclone/rclone.conf"
2021/05/02 14:40:13 DEBUG : rclone: Version "v1.55.1" starting with parameters ["rclone" "copy" "--local-encoding" "None" "-vv" "a‛/b" "gdrive:"]
2021/05/02 14:40:13 DEBUG : Creating backend with remote "a‛/b"
2021/05/02 14:40:13 DEBUG : local: detected overridden config - adding "{sb0+v}" suffix to name
2021/05/02 14:40:13 DEBUG : fs cache: adding new entry for parent of "a‛/b", "local{sb0+v}:/tmp/tmp.nIO15081l8"
2021/05/02 14:40:13 DEBUG : Creating backend with remote "gdrive:"
2021/05/02 14:40:13 DEBUG : a‛/b: Need to transfer - File not found at Destination
2021/05/02 14:40:14 DEBUG : a‛/b: MD5 = d41d8cd98f00b204e9800998ecf8427e OK
2021/05/02 14:40:14 INFO  : a‛/b: Copied (new)
2021/05/02 14:40:14 INFO  :
Transferred:             0 / 0 Bytes, -, 0 Bytes/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         1.3s

2021/05/02 14:40:14 DEBUG : 5 go routines active

With other full width character it works as expected without ‛.

uu@hh /tmp/tmp.nIO15081l8 % rclone copy --local-encoding None -vv 'a?b' gdrive:
2021/05/02 14:45:00 DEBUG : Using config file from "/home/uu/.config/rclone/rclone.conf"
2021/05/02 14:45:00 DEBUG : rclone: Version "v1.55.1" starting with parameters ["rclone" "copy" "--local-encoding" "None" "-vv" "a?b" "gdrive:"]
2021/05/02 14:45:00 DEBUG : Creating backend with remote "a?b"
2021/05/02 14:45:00 DEBUG : local: detected overridden config - adding "{sb0+v}" suffix to name
2021/05/02 14:45:00 DEBUG : fs cache: adding new entry for parent of "a?b", "local{sb0+v}:/tmp/tmp.nIO15081l8"
2021/05/02 14:45:00 DEBUG : Creating backend with remote "gdrive:"
2021/05/02 14:45:00 DEBUG : a?b: Need to transfer - File not found at Destination
2021/05/02 14:45:01 DEBUG : a?b: MD5 = d41d8cd98f00b204e9800998ecf8427e OK
2021/05/02 14:45:01 INFO  : a?b: Copied (new)
2021/05/02 14:45:01 INFO  :
Transferred:             0 / 0 Bytes, -, 0 Bytes/s, ETA -
Transferred:            1 / 1, 100%
Elapsed time:         1.1s

2021/05/02 14:45:01 DEBUG : 4 go routines active

When listing it seems opposite of what should happen.

uu@hh /tmp/tmp.nIO15081l8 % rclone lsf --local-encoding None .
a‛/b
a?b
uu@hh /tmp/tmp.nIO15081l8 % rclone lsf .
a/b
a?b

How to use GitHub

  • Please use the 👍 reaction to show that you are affected by the same issue.
  • Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
  • Subscribe to receive notifications on status change and new comments.

Activity

  1. ncw commented on May 3, 2021

    @ncw
    Member

    This is to do with the fact that drive file names can have / in, so rclone translates to and from /.

    Are you trying to upload a file with a / in to google drive? If so you want to use --drive-encoding Slash rather than turning off the encoding locally.

  2. ncw commented on May 4, 2021

    @ncw
    Member

    This works for me

    $ rclone-v1.55.1 copy -vv --drive-encoding Slash 'a/b' drive:
    2021/05/04 09:54:30 DEBUG : Using config file from "/home/ncw/.rclone.conf"
    2021/05/04 09:54:30 DEBUG : rclone: Version "v1.55.1" starting with parameters ["rclone-v1.55.1" "copy" "-vv" "--drive-encoding" "Slash" "a/b" "drive:"]
    2021/05/04 09:54:30 DEBUG : Creating backend with remote "a/b"
    2021/05/04 09:54:30 DEBUG : fs cache: adding new entry for parent of "a/b", "/tmp/issue-5298"
    2021/05/04 09:54:30 DEBUG : Creating backend with remote "drive:"
    2021/05/04 09:54:30 DEBUG : drive: detected overridden config - adding "{ODuEZ}" suffix to name
    2021/05/04 09:54:30 DEBUG : fs cache: renaming cache item "drive:" to be canonical "drive{ODuEZ}:"
    2021/05/04 09:54:30 DEBUG : a/b: Need to transfer - File not found at Destination
    2021/05/04 09:54:32 DEBUG : a/b: MD5 = d41d8cd98f00b204e9800998ecf8427e OK
    2021/05/04 09:54:32 INFO  : a/b: Copied (new)
    2021/05/04 09:54:32 INFO  : 
    Transferred:   	         0 / 0 Bytes, -, 0 Bytes/s, ETA -
    Transferred:            1 / 1, 100%
    Elapsed time:         1.8s
    
    2021/05/04 09:54:32 DEBUG : 4 go routines active
    

    Do you have other config in the config file - eg a local section?

    Can you do this please on your test file directory

    $ ls -l
    total 0
    -rw-rw-r-- 1 ncw ncw 0 May  3 07:00 a/b
    
  3. ncw commented on May 14, 2021

    @ncw
    Member

    To be able to copy this file as a?b I have to pass --local-encoding None. Both / and ? are both disallowed on Windows but allowed in Google Drive, I don't understand why these require different flags.

    That is because / is translated by the google drive backend whereas ? isn't.

  4. ncw commented on May 16, 2021

    @ncw
    Member

    That is a good explanation.

    This is extremely confusing behaviour not documented anywhere as far as I can tell, and the documentation erroneously states Slash is encoding to the half-width slash.

    Would you like to propose an update to the docs?

  5. added this to the v1.57 milestone on May 16, 2021
  6. modified the milestones: v1.57, Known Problem on Nov 1, 2021
  7. ximellon commented on Jan 9, 2022

    @ximellon

    First of all

    Therefore to preserve all full-width characters, the correct option is --backend-encoding Slash.

    This is obviously not true. As you can view from the code, all other full-width characters, except Slash, are also controlled by their half-width counterpart separately.

    And I also think @ncw 's solution isn't good. --local-encoding None is to tell rclone not to do the conversion. But --drive-encoding Slash is to tell rclone do another conversion to fix (reverse) the previous conversion. The result is the same. But the thoughts behind are quite different.


    I guess I figure it out where the problem is: you do the conversion in 2 passes.

    1. you escape the path with restricted characters AND you also convert some characters (basically, full-width Slash) in filename since if you don't do that, you won't be able to tell them apart.
    2. you do another conversion (encoding/decoding) when it goes to the real transmission.

    The problem happens after phase 1. As I observed, rclone tends to take the result of phase 1 + decoding (based on your configuration) to match with your command arguments. So you cannot purely specify / (full-width Slash) with --local-encoding None since it has already got escaped as ‛/ and won't be converted back to / based on the None configuration.

    @cuevavirus also mentioned that he cannot do copy command with --drive-encoding Question. The problem is probably not on the Google Drive side. but the local conversion. Since he did it on Windows, ? (full-width Question) will be encoding to ? (half-width Question) by default. which causes rclone couldn't find the target if he specified the argument with ? (full-width Question).

    A simple test based on the latest rclone:

    C:\Users\user\Desktop\temp>rclone version
    rclone v1.57.0
    - os/version: Microsoft Windows 10 Home 2009 (64 bit)
    - os/kernel: 10.0.19043.1415 (x86_64)
    - os/type: windows
    - os/arch: amd64
    - go/version: go1.17.2
    - go/linking: dynamic
    - go/tags: cmount
    
    C:\Users\user\Desktop\temp>rclone ls ./
            0 ?.txt
            0 /.txt
    
    C:\Users\user\Desktop\temp>rclone ls ./ --local-encoding None
            0 ‛/.txt
            0 ?.txt
    
    C:\Users\user\Desktop\temp>dir
     磁碟區 C 中的磁碟是 S3A9794D002
     磁碟區序號:  2CE9-C6CA
    
     C:\Users\user\Desktop\temp 的目錄
    
    22-01.10  01:04    <DIR>          .
    22-01.10  01:04    <DIR>          ..
    22-01.10  01:03                 0 /.txt
    22-01.10  01:03                 0 ?.txt
                   2 個檔案               0 位元組
                   2 個目錄  162,120,818,688 位元組可用
    
    C:\Users\user\Desktop\temp>
    

    To fix this weird issue without changing a lot. Here's my idea:

    1. Escape / (separator for path?) with characters different from full-width Slash so that you won't need to do filename escaping at phase 1.
    2. Use this result WITHOUT applying encoding to match arguments so that it could be more intuitive for user to understand and won't cause this kind of weird issue.

    I could understand you must put a lot of effort to do these conversions to keep filename consistent. But for me, I think an extra file to record what has been changed to the filenames is good enough and much simpler, easier to implement. Finally, if you could show some message (at the beginning or ending) to tell users that their filename could somewhat be changed, it would be fantastic!

    Thank you.

    NB. I still might be wrong with this issue. And there could be a better solution for it.

    P.S. I'm from Asia region. So basically we use full-width characters more often. And that's why my English isn't good. Feel free to discuss with me if you couldn't understand what I'm talking about. I'll do my best to explain my thought. =)

  8. ximellon commented on Jan 10, 2022

    @ximellon

    I believe as long as the two remotes involved have the same encoding option the filenames will be preserved.

    True. But not the right way since the whole process takes two conversion, which is not our (at least my) willing then.

    or simply --local-encoding Slash

    This is not true. I've tested it. As I expected, with default gdrive encoding setup (InvlidUtf8 only) and --local-encoding Slash (on Windows), by specifying / (full-width Slash), you'll finally got / (half-width Slash) in your filename on gdrive side, which is inconsistent with your command argument. And this is the reason why I thought you should fix it. It's so weird and counterintuitive.

    I think I might be wrong with the two-pass conversion. There's no 2nd pass but the receive end decoding. And it causes some weird situation when you using full-width characters in your filename since you simply normalize their counterpart half-width one to full-width, you must do some other conversion for it or you won't be able to tell them apart.

    Conclusion:

    1. You still make things complicated by doing some implicit filename conversion.
    2. You should fix the decoding behavior before matching with command arguments. Before then, I'll tend to specify ‛/ explicitly since it should be the right way (no conversion) to get things done.
    3. Or you should at least documented that ‛/ is the only (or else?) exception for implicit conversion even when you set encoding to None on both side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions