Linux agent CLI - how does work syncstate?

Hi everybody,

I have questions about the Linux agent Cli and more precisely with syncstate option.

  1. When I use this option on a path that contains hundred of directories, it display to me only a state about around twenty directories.

  2. Did the state displayed at the top (Synced, Not Synced) is about certains directories and sub-directories or only those displayed ?

In short, how does work syncstate ?

Thanks !

Hi @ugloo,
It does look like syncstate has a listing issue with large folders. I am seeing truncation of the items in a 700 items folder and it only showing about 300 items. This is something we will need to look at.

The very first item is the state of the path you selected. So if you do this on a folder, the first item will be the state of the folder. This is as its tracked in odrive, so it isn’t influenced by the listing truncation above.

Can you tell me what information you are trying to gather? We can work around the limitation here, but I would need a bit more info on the use case.

Thanks for your answer.
I want to be sure that when I have a “synced” status for a directory path, it is about the directory himself and its subdirectories and files.

Hi @ugloo,
The folder syncstate can be deceiving because it can say “Synced” if there are placeholder files in the structure. This is because an odrive folder is considered “Synced” if there are no files in it to upload.


To get a listing of all files/folders that have not been downloaded/expanded yet within a folder structure, you can run this command:
path="$HOME/odrive-agent-mount"; find "$path" -name "*.cloud*"


To get a listing of all files that have not been uploaded yet within a folder structure, you can run this command:
path="$HOME/odrive-agent-mount"; odrive_cli="$HOME/.odrive-agent/bin/odrive.py"; find "$path" -type f -not -name "*.cloud*" -print0 | xargs -0 -n 1 -P 4 python "$odrive_cli" syncstate --textonly | grep "Not Synced"


To get a report of all files/folders that have not been downloaded or uploaded yet within a folder structure, you can run this command:
path="$HOME/odrive-agent-mount"; odrive_cli="$HOME/.odrive-agent/bin/odrive.py"; echo "Not uploaded yet:"; find "$path" -type f -not -name "*.cloud*" -print0 | xargs -0 -n 1 -P 4 python "$odrive_cli" syncstate --textonly | grep "Not Synced"; echo "Not downloaded yet:";find "$path" -name "*.cloud*"


path="$HOME/odrive-agent-mount" can be changed to a specific folder in odrive, like path="$HOME/odrive-agent-mount/Amazon Drive/My Folder"

odrive_cli="$HOME/.odrive-agent/bin/odrive.py" shoudl be changed to where you have stored the CLI.


Keep in mind that certain files will not be synced. Here is the list of those: https://docs.odrive.com/docs/sync-changes#section--ignore-list-

NOTE: You will probably need to download a new version of the odrive cli client here to use the ‘–textonly’ parameter: https://dl.odrive.com/odrive-py

It looks like this cli version “https://dl.odrive.com/odrive-py” is the good one for us. Before, we were using the binary version.
Currently, we write results of the syncstate command inside a file by redirecting output, but some errors happened during file writing. We had to overwrite “sys.stderr.write / sys.stdout.write” functions to do that :

def stdewrite(s):
sys.stderr.write(s.encode(‘utf-8’))

def stdowrite(s):
sys.stdout.write(s.encode(‘utf-8’))

Thanks !

Thanks for the update @ugloo! I am always interested in how people are using the product, especially in these more advanced cases.

If you are able to share your workflow/scripts/further CLI modifications here, I (and I’m sure others) would be appreciative. Only if it is possible and you are comfortable with it, of course. I realize there may be pieces that are sensitive/private and cannot be shared.

Please, find the result of a diff between the current version (at 05/26/2017) of “https://s3.amazonaws.com/cdn-agent.odrive.com/preview4/odrive.py” and ours :

shell> diff odrive.py our-odrive.py
29a30,37
> 
> def stdewrite(s):
> 	sys.stderr.write(s.encode('utf-8'))
> 
> def stdowrite(s):
> 	sys.stdout.write(s.encode('utf-8'))
> 
> 
195c203
<                 sys.stderr.write('{}{}{}'.format(color, message, OdriveSynchronousCommand._END_COLOR))
---
>                 stdewrite('{}{}{}'.format(color, message, OdriveSynchronousCommand._END_COLOR))
197c205
<                 sys.stderr.write(message)
---
>                 stdewrite(message)
201c209
<                 sys.stdout.write('{}{}{}'.format(color, message, OdriveSynchronousCommand._END_COLOR))
---
>                 stdowrite('{}{}{}'.format(color, message, OdriveSynchronousCommand._END_COLOR))
203c211
<                 sys.stdout.write(message)
---
>                 stdowrite(message)
567a576,577
>     TEXTONLY_ARGUMENT_HELP = "display file and folder states with text rather than color"
>     TEXTONLY_ARGUMENT_NAME = '--textonly'
569c579,580
<     def __init__(self, agentPort, desktopPort, path):
---
> 
>     def __init__(self, agentPort, desktopPort, path, textonly):
571a583
>         self._textonly = textonly
595c607,610
<                     supportsColor = self._supports_color()
---
>                     if self._textonly:
>                         supportsColor = False
>                     else:
>                         supportsColor = self._supports_color()
1008a1024,1026
>     syncStateParser.add_argument(SyncState.TEXTONLY_ARGUMENT_NAME,
>                                  action='store_true',
>                                  help=SyncState.TEXTONLY_ARGUMENT_HELP)
1159c1177,1178
<                             path=os.path.abspath(expand_user(getattr(args, SyncState.PATH_ARGUMENT_NAME))))
---
>                             path=os.path.abspath(expand_user(getattr(args, SyncState.PATH_ARGUMENT_NAME))),
>                             textonly=args.textonly)

We hope that will be useful and there are no mistakes in it.

1 Like