iwonbigbro/gsync

Return code appears to always be 0, even after a failure.

Opened this issue · 1 comments

I receive a lot of errors when uploading similar to this:

DEBUG: <HttpError 503 when requesting https://www.googleapis.com/drive/v2/files?q=<redacted>%22+in+parents+and+trashed+%3D+false&alt=json returned "Backend Error">:   File "/usr/local/lib/python2.7/dist-packages/libgsync/crawler.py", line 150, in run
    self._walk(srcpath, self._walkCallback, self._dev)
  File "/usr/local/lib/python2.7/dist-packages/libgsync/crawler.py", line 124, in _walk
    self._sync(f)
  File "/usr/local/lib/python2.7/dist-packages/libgsync/sync/__init__.py", line 31, in __call__
    self._sync(path)
  File "/usr/local/lib/python2.7/dist-packages/libgsync/sync/__init__.py", line 64, in _sync
    dstFile = self.dst.getInfo(relPath)
  File "/usr/local/lib/python2.7/dist-packages/libgsync/sync/file/remote/__init__.py", line 61, in getInfo
    info = drive.stat(path)
  File "/usr/local/lib/python2.7/dist-packages/libgsync/drive/__init__.py", line 507, in stat
    ents = self._query(parentId = parentId)
  File "/usr/local/lib/python2.7/dist-packages/libgsync/drive/__init__.py", line 790, in _query
    files = service.files().list(**param).execute()
  File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 132, in positional_wrapper
    return wrapped(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 723, in execute
    raise HttpError(resp, content, uri=self.uri)

Error: <HttpError 503 when requesting https://www.googleapis.com/drive/v2/files?q=<redacted>%22+in+parents+and+trashed+%3D+false&alt=json returned "Backend Error">

There already appear to be bugs for many similar errors, however I'd like gsync to return a non-zero value when this happens. This would enable me to hackishly implement retries via a simple bash for loop:

while $? -ne 0; do
  gsync local/path/ drive://remote/path/
done

I actually have the same problem. I've implemented this code but the script seems always to return 0.
I there a way around it?

Thx,

Luigi

#Sync the files
gsync -r -t -v --progress --delete "$sourcepath" "$targetpath"

if [ "$?" -ne 0 ]; then
echo
echo "Error in syncing"
echo
exit 1
else
echo
echo "Sync Completed"
echo
fi

exit 0