Open lionandoil opened 10 years ago
Just figured out that it works if I omit the root-slash in the Drive path, i.e. if I do any of
gsync -r foo drive://
gsync -r foo/ drive://foo
cd foo & gsync -r . drive://foo
Which one is the intended way to specify drive paths, with our without the initial slash? The only example usage in --help is with the preceding slash, it's strange that it accepts it first but then fails once it goes one directory deeper...
The first time (and only the first time) I do the upload/file creation it still spits out the error message mentioned in #30 - it doesn't just print it out in --debug though, but it goes to stderr as well, despite the synchronisation/upload succeeding. Here's the debug output from where it starts to differ from the one above, i.e. after it successfully created foo3/ remotely:
DEBUG: crawler.py:123:_walk(): Synchronising file: 'foo3/bar'
DEBUG: sync/:34:_sync(): Synchronising: 'foo3/bar'
DEBUG: sync/file/:338:relativeTo(): Creating relative path from '^./+' and 'foo3/bar'
DEBUG: sync/:37:_sync(): Destination: SyncFileRemote('drive://')
DEBUG: sync/:38:_sync(): Relative: 'foo3/bar'
DEBUG: sync/file/:193:getPath(): Joining: '.' with 'foo3/bar'
DEBUG: sync/file/local/:30:getInfo(): Fetching local file metadata: './foo3/bar'
DEBUG: sync/file/local/:59:getInfo(): Local mtime: SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160559, tzinfo=tzutc()))
DEBUG: sync/file/local/:64:getInfo(): Local mtime: 2013-11-30T14:21:12.160559+00:00
DEBUG: sync/:52:_sync(): force_dest_file = False
DEBUG: sync/file/remote/:31:getPath(): Joining: '/' with 'foo3/bar'
DEBUG: sync/file/remote/:34:getPath(): * got: 'drive://foo3/bar'
DEBUG: sync/file/remote/:31:getPath(): Joining: '/' with 'foo3/bar'
DEBUG: sync/file/remote/:34:getPath(): * got: 'drive://foo3/bar'
DEBUG: sync/file/remote/:56:getInfo(): Fetching remote file metadata: 'drive://foo3/bar'
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:488:stat(): Got 3 paths from pathlist('drive://foo3/bar')
DEBUG: drive/:489:stat(): Got paths: ['drive://', 'foo3', 'bar']
DEBUG: drive/:497:stat(): Searching for 'foo3' in path 'drive://'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://foo3'
DEBUG: drive/:497:stat(): Searching for 'bar' in path 'drive://foo3'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:506:stat(): * nothing found
DEBUG: drive/:758:_query(): Checking gcache for parentId: 0B_9WraFp7iOpRmg5Slg4elNrRlk
DEBUG: drive/:788:_query(): Executing query: {'q': '"0B_9WraFp7iOpRmg5Slg4elNrRlk" in parents and trashed = false'}
DEBUG: drive/:792:_query(): Query returned 4 files
DEBUG: drive/:799:_query(): Updating google cache: 0B_9WraFp7iOpRmg5Slg4elNrRlk (0 items)
DEBUG: drive/:509:stat(): Got 0 entities back
DEBUG: sync/file/remote/:63:getInfo(): File not found: 'drive://foo3/bar'
DEBUG: sync/:65:_sync(): Defaulting destination directory: 'drive://foo3/bar'
DEBUG: sync/:71:_sync(): File not found: 'drive://foo3/bar'
DEBUG: sync/file/:347:islocal(): self.__class__.__name__ == SyncFileRemote
foo3/bar
DEBUG: sync/file/:280:_normaliseSource(): type(src) = <class 'libgsync.sync.file.SyncFileInfo'>
DEBUG: sync/file/factory.py:10:create(): SyncFileFactory.create('./foo3/bar')
DEBUG: sync/file/factory.py:25:create(): Creating SyncFileLocal('foo3/bar')
DEBUG: sync/file/remote/:80:_createFile(): Creating remote file: 'drive://foo3/bar'
DEBUG: sync/file/local/:30:getInfo(): Fetching local file metadata: 'foo3/bar'
DEBUG: sync/file/local/:59:getInfo(): Local mtime: SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160559, tzinfo=tzutc()))
DEBUG: sync/file/local/:64:getInfo(): Local mtime: 2013-11-30T14:21:12.160559+00:00
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3'
DEBUG: drive/:466:stat(): Found path in path cache: 'drive://foo3'
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:488:stat(): Got 3 paths from pathlist('drive://foo3/bar')
DEBUG: drive/:489:stat(): Got paths: ['drive://', 'foo3', 'bar']
DEBUG: drive/:497:stat(): Searching for 'foo3' in path 'drive://'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://foo3'
DEBUG: drive/:497:stat(): Searching for 'bar' in path 'drive://foo3'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:506:stat(): * nothing found
DEBUG: drive/:758:_query(): Checking gcache for parentId: 0B_9WraFp7iOpRmg5Slg4elNrRlk
DEBUG: drive/:509:stat(): Got 0 entities back
DEBUG: drive/:728:_clearCache(): Clearing path cache entries for ''drive://foo3/bar''...
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:488:stat(): Got 3 paths from pathlist('drive://foo3/bar')
DEBUG: drive/:489:stat(): Got paths: ['drive://', 'foo3', 'bar']
DEBUG: drive/:497:stat(): Searching for 'foo3' in path 'drive://'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://foo3'
DEBUG: drive/:497:stat(): Searching for 'bar' in path 'drive://foo3'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:506:stat(): * nothing found
DEBUG: drive/:758:_query(): Checking gcache for parentId: 0B_9WraFp7iOpRmg5Slg4elNrRlk
DEBUG: drive/:509:stat(): Got 0 entities back
DEBUG: sync/file/remote/:91:_updateFile(): Updating remote file: 'drive://foo3/bar'
DEBUG: sync/file/local/:30:getInfo(): Fetching local file metadata: 'foo3/bar'
DEBUG: sync/file/local/:59:getInfo(): Local mtime: SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160559, tzinfo=tzutc()))
DEBUG: sync/file/local/:64:getInfo(): Local mtime: 2013-11-30T14:21:12.160559+00:00
DEBUG: sync/file/local/:30:getInfo(): Fetching local file metadata: 'foo3/bar'
DEBUG: sync/file/local/:59:getInfo(): Local mtime: SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160559, tzinfo=tzutc()))
DEBUG: sync/file/local/:64:getInfo(): Local mtime: 2013-11-30T14:21:12.160559+00:00
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:466:stat(): Found path in path cache: 'drive://foo3/bar'
DEBUG: drive/:681:update(): Updating: 'drive://foo3/bar'
DEBUG: drive/:688:update(): * with: 'mimeType' = 'none/unknown-mimetype'
DEBUG: drive/:688:update(): * with: 'fileSize' = 0
DEBUG: drive/:688:update(): * with: 'modifiedDate' = SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160559, tzinfo=tzutc()))
DEBUG: drive/:688:update(): * with: 'statInfo' = posix.stat_result(st_mode=33188, st_ino=7865630, st_dev=64515L, st_nlink=1, st_uid=1000, st_gid=1000, st_size=0, st_atime=1385821290, st_mtime=1385821272, st_ctime=1385821272)
DEBUG: drive/:688:update(): * with: 'title' = 'bar'
DEBUG: drive/:688:update(): * with: 'path' = 'foo3/bar'
DEBUG: drive/:688:update(): * with: 'md5Checksum' = None
DEBUG: drive/:688:update(): * with: 'description' = 'eJx9j8sKg0AMRff5EV3JPMw8fqAguGo/YLA6C1FxMGMX/fqOrcW6KYRwuZwTSDsTuKkZvKPYRLd4WscIgUOeV1JyY6DSRqGSDGpVIscaKp6GMfbdW5AGjeDC/mQtTjnmXRBwyyi6NvaTzyBIuBxAwRVDNBrozSydfySk3M5/mmm38I91H+d2oASpw2t2Tx+eZYVAcfIG6p8blf4tmVVA8RosFC/Pt0ml'
DEBUG: drive/:691:update(): mdeia_body type = <class 'apiclient.http.MediaFileUpload'>
DEBUG: drive/:708:update(): * uploading next chunk...
DEBUG: drive/:713:update(): Exception: <HttpError 400 when requesting https://www.googleapis.com/upload/drive/v2/files/0B_9WraFp7iOpV3Myb3BIR1BPY1E?uploadType=resumable&alt=json&newRevision=true&setModifiedDate=false returned "Invalid Upload Request">
DEBUG: 'Exception': File "/usr/local/lib/python2.7/dist-packages/libgsync/drive/__init__.py", line 711, in update
status, res = req.next_chunk()
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 874, in next_chunk
return self._process_response(resp, content)
File "/usr/local/lib/python2.7/dist-packages/apiclient/http.py", line 901, in _process_response
raise HttpError(resp, content, uri=self.uri)
DEBUG: sync/file/remote/:116:_updateFile(): Update failed
DEBUG: sync/file/local/:30:getInfo(): Fetching local file metadata: 'foo3/bar'
DEBUG: sync/file/local/:59:getInfo(): Local mtime: SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160559, tzinfo=tzutc()))
DEBUG: sync/file/local/:64:getInfo(): Local mtime: 2013-11-30T14:21:12.160559+00:00
DEBUG: sync/file/:242:__updateStats(): Updating: 'drive://foo3/bar'
DEBUG: sync/file/:270:__updateStats(): * Updating with mtime: 1385821420.38
DEBUG: sync/file/:271:__updateStats(): * Updating with atime: 1385821290.25
DEBUG: sync/file/remote/:122:_updateStats(): Updating remote file stats: 'drive://foo3/bar'
DEBUG: sync/file/remote/:31:getPath(): Joining: '/' with '/foo3/bar'
DEBUG: sync/file/remote/:34:getPath(): * got: 'drive://foo3/bar'
DEBUG: sync/file/remote/:56:getInfo(): Fetching remote file metadata: 'drive://foo3/bar'
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:466:stat(): Found path in path cache: 'drive://foo3/bar'
DEBUG: sync/file/remote/:68:getInfo(): Remote mtime: SyncFileInfoDatetime(datetime.datetime(2013, 11, 30, 14, 21, 12, 160000, tzinfo=tzutc()))
DEBUG: drive/:462:stat(): Checking pcache for path: 'drive://foo3/bar'
DEBUG: drive/:466:stat(): Found path in path cache: 'drive://foo3/bar'
DEBUG: drive/:681:update(): Updating: 'drive://foo3/bar'
DEBUG: drive/:688:update(): * with: 'description' = 'eJxtjk0Kg0AMRve5iK5kfsxMvEBBkC7aAwxWZyEqDk7aRU/faasLQQghyXsfpFsiuLkdvYvcslt9fE4MQUKe11pLIqgtGTRaQGNKlNhALVMJIfYu4CI1ISmpKlEoVIhkE9xuVh1mzvug4J5Fdh0Ps88g6IMQf2zt/SuhEq7/fd5cPHEf09KNMUGz2+1m29PX9tQYh/fXohTjW6ig+ABwSkbK'
DEBUG: drive/:688:update(): * with: 'modifiedDate' = '2013-11-30T14:23:40.383411'
DEBUG: drive/:691:update(): mdeia_body type = <type 'NoneType'>
sent 0 bytes received 0 bytes 0.00 bytes/sec
DEBUG: /usr/local/bin/gsync:66:<module>(): Crawlers finished, exiting
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
This does look like a new bug. I'll look into this asap.
The path munging is supposed to strip off the drive:// part leaving just the absolute path under Google Drive root. However, if something is failing with this, it might be generating an invalid path. I'll take a look through the debug output at my earliest opportunity.
Wow, this is interesting. The file being opened (with the filename that is too long) is the httplib local cache. I have no idea at this stage, why omitting the extra slash has anything to do with the cache name that is generated, since the filenames have nothing to do with the URI in google drive. Files are all accessed via a UUID.
So the API query made in the first (failing) run:
{'q': '"0B_9WraFp7iOpRFE5T0lBcWpnTVk" in parents and trashed = false'}
The query in the second (working) run:
{'q': '"0B_9WraFp7iOpRmg5Slg4elNrRlk" in parents and trashed = false'}
A subtle difference in the ID being requested, which is odd. I will see if there is a known issue with httplib...
https://code.google.com/p/httplib2/issues/detail?id=92
Looks like I could do something to mitigate the issue.
Hi,
same problem, with or without extra slash... Running on Ubuntu server 12.04 LTS, Python 2.7.3, Gsync 0.1.14 installed git cloning. Any suggested workaround?
DEBUG: IOError(36, 'File name too long'): [Errno 36] File name too long: '/home/paolo/.gsync/http_cache/www.googleapis.com,drive,v2,files,q=%22root%22+in+parents+and+trashed+%3D+false&pageToken=EAIaowELEgBSmgEKkAEKafjzZuv_____wxLMErNCyUAA_wH__kNvc21vLnVzZXIoMDAwMDAwNWYwODVlNTdiYVUpLmRpcl9lbnRyeSg0MDgxNj,aa07a32f36e29b0562bfada40b080270'
DEBUG: IOError(36, 'File name too long'): File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/EGG-INFO/scripts/gsync", line 82, in main
Crawler(src, dest).run()
File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/crawler.py", line 76, in __init__
info = self._drive.stat(self._dst)
File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/drive/__init__.py", line 665, in stat
ents = self._query(parent_id=parent_id)
File "/usr/local/lib/python2.7/dist-packages/retrying-1.2.3-py2.7.egg/retrying.py", line 92, in wrapped_f
return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/retrying-1.2.3-py2.7.egg/retrying.py", line 253, in call
raise attempt.get()
File "/usr/local/lib/python2.7/dist-packages/retrying-1.2.3-py2.7.egg/retrying.py", line 285, in get
reraise(self.value[0], self.value[1], self.value[2])
File "/usr/local/lib/python2.7/dist-packages/retrying-1.2.3-py2.7.egg/retrying.py", line 241, in call
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/usr/local/lib/python2.7/dist-packages/gsync-0.1.14-py2.7.egg/libgsync/drive/__init__.py", line 939, 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 716, in execute
body=self.body, headers=self.headers)
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/oauth2client/client.py", line 490, in new_request
redirections, connection_type)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1593, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 1396, in _request
_updateCache(headers, response, content, self.cache, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 448, in _updateCache
cache.set(cachekey, text)
File "/usr/local/lib/python2.7/dist-packages/httplib2/__init__.py", line 715, in set
f = file(cacheFullPath, "wb")
gsync: [Errno 36] File name too long: '/home/paolo/.gsync/http_cache/www.googleapis.com,drive,v2,files,q=%22root%22+in+parents+and+trashed+%3D+false&pageToken=EAIaowELEgBSmgEKkAEKafjzZuv_____wxLMErNCyUAA_wH__kNvc21vLnVzZXIoMDAwMDAwNWYwODVlNTdiYVUpLmRpcl9lbnRyeSg0MDgxNj,aa07a32f36e29b0562bfada40b080270'
gsync error: IOError at drive(939) [client=0.1.14]
Can I help you in debugging / fixing issue?
Regards.
Paolo
same issue here
DEBUG: drive/:284:_getConfigDir(): Config dir = /home/jeremy/.gsync
DEBUG: drive/:242:service(): Loading Google Drive service from config
DEBUG: drive/:246:service(): Downloading API service
DEBUG: drive/:263:service(): Building Google Drive service from document
DEBUG: drive/:788:_query(): Executing query: {'q': '"root" in parents and trashed = false'}
DEBUG: drive/:792:_query(): Query returned 4 files
DEBUG: drive/:799:_query(): Updating google cache: root (35 items)
DEBUG: drive/:509:stat(): Got 35 entities back
DEBUG: drive/:445:_findEntity(): Iterating 35 entities to find 'backups'
DEBUG: drive/:450:_findEntity(): comparing u'backups' to u'backups'
DEBUG: drive/:452:_findEntity(): Found u'backups'
DEBUG: drive/:497:stat(): Searching for 'rawphotos' in path 'drive://backups'
DEBUG: drive/:503:stat(): Checking pcache for path: 'drive://backups/rawphotos'
DEBUG: drive/:506:stat(): * nothing found
DEBUG: drive/:758:_query(): Checking gcache for parentId: 0B55M-kBru5L2WnJNaVdNbGtjajQ
DEBUG: drive/:788:_query(): Executing query: {'q': '"0B55M-kBru5L2WnJNaVdNbGtjajQ" in parents and trashed = false'}
DEBUG: IOError(36, 'File name too long'): File "/usr/local/bin/gsync", line 55, in <module>
crawler = Crawler(p, dest)
File "/usr/local/lib/python2.7/dist-packages/libgsync/crawler.py", line 57, in __init__
info = self._drive.stat(self._dst)
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 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/http.py", line 722, in execute
body=self.body, headers=self.headers)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/oauth2client/client.py", line 551, in new_request
redirections, connection_type)
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1569, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 1374, in _request
_updateCache(headers, response, content, self.cache, cachekey)
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 447, in _updateCache
cache.set(cachekey, text)
File "/usr/lib/python2.7/dist-packages/httplib2/__init__.py", line 714, in set
f = file(cacheFullPath, "wb")
Error: [Errno 36] File name too long: '/home/jeremy/.gsync/http_cache/www.googleapis.com,drive,v2,files,q=%220B55M-kBru5L2WnJNaVdNbGtjajQ%22+in+parents+and+trashed+%3D+false&alt=json,1f03b05e5315d003d9962037dad51472'
close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr
paths don't matter I can't get anything to happen.
I believe I fixed mine, seems to have been due to an outdated httplib2 which was not upgraded due to a permissions problem.
Hello,
when I try to upload a new directory with content it successfully creates the top directory on Drive but then fails with an IOError when uploading/creating the actual content, whether that content is a directory or file. Reproducable in the following ways, error message below:
I get the following output: