Odrivecli.py sync is "recursive only"

I am trying to use the python scripts to automate some of my odrive activities and I was attempting to use the latest version of odrivecli.pyfrom https://github.com/amagliul/odrive-utilities and I am finding that it appears to sync recursively by default, which would imply that it can only sync recursively. I am actually looking to write a script that will unsync a single file in a path which I intend (unintentionally ironically) to perform recursively by first confirming that the next tier of the hierarchy exists and then running this command on that sub-tier until the it reaches the last element of the path which could either be a file or a directory.

I am new to python so I am not sure why it is recursively syncing everything beneath the location specified, but seeing as default behavior appears to be stated to just sync the specified file or folder only and not its contents as it would if recursion was specified explicitly. @Tony, seeing that the avatar of the owner of the repository in Github is the same as yours here (just as mine is, incidentally) I am assuming you are the author or at least the curator of this code. Do you know what the intended behavior is and how I might best achieve a non recursive sync and unsync on the CLI so I can script what I am describing? Again, Python is preferred as I am trying to make use of it in order to familiarize myself with it lest I just write it in Ruby. :stuck_out_tongue_closed_eyes: I am willing to fork your repo and alter this script so that it behaves this the usage describes (once I understand it) but I figured I should ask you first before going through the trouble. Thanks.

Hi @DarfNader,
I haven’t looked at it for a while, but it should not be syncing recursively by default. It should require the --recursive option in order to perform a recursive sync.

The code to perform the recursive sync is here: https://github.com/amagliul/odrive-utilities/blob/master/odrivecli.py#L478

I’ll try to test it out in a bit, but I don’t see how it would enter this code by default.

What OS are you running and are you running this against the desktop client or the sync agent?

You can also try the official CLI from here: https://dl.odrive.com/odrive-py
The one in my github was a fork I made to “unofficially” add recursive sync and a few other changes.

It’s MacOS 10.14.5 and python 3.7.3

Hi @DarfNader,
I tried the odrivecli from my github against the Linux agent and the Mac desktop client and wasn’t able to reproduce a recursive sync when using a basic sync command on a folder like
python3 odrivecli.py sync ~/odrive/Dropbox.cloudf

Can you tell me what command you are running?

If you are using the desktop client (vs the agent) do you have an auto-download rules set that could be trigged as you are expanding folders? https://docs.odrive.com/docs/sync-source-changes#section-configure-global-and-folder-sync-rules

I am actually trying to use the MacOS binary version of odrive and I am trying to get around the problem where odrive sync doesn’t accept more than one argument by doing the following to sync all files in a directory with
find . -name "*.cloud" -exec odrive sync '{}' \;
and I will get
find: odrive: No such file or directory
find: odrive: No such file or directory
find: odrive: No such file or directory
for each instance.
I try the same format but with echo and I get output perfectly:
find . -name "*.cloud" -exec echo '{}' \;
a a a.cloud
b b b.cloud
So there seems to be something staring with the odrive command when pipelining to it.

Hi @DarfNader,
Do you have the odrive binary in your path? I would expect that error message if the find command is unable to find the odrive binary to execute it. Try adding the full path of the odrive binary and see if that makes a difference.

I found the problem. Subtle one! odrive was in ~/bin and my $PATH had it as ~/bin instead of $HOME/bin which confuses things. It will normally resolve but which doesn’t so clearly the behavior in the shell is quite different! Once I got that it worked just fine.

1 Like