kotarokawamura / httplib2

Automatically exported from code.google.com/p/httplib2
0 stars 0 forks source link

233 character cache filenames leave little room for full path on Windows #293

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Windows has a 260 character limit on a file's full path: http://goo.gl/kFdSl

2. URLs can be really long, especially when using the google-api-python-client. 
__init__.py/safename() function limits length to 233 characters (200 from URL + 
, + 32 character md5sum)

3. This leaves only 27 characters for the cache path which is rather short. If 
for instance, the program is stored in:

\Program Files\program\cache\  (29 chars)

then URLs longer than 198 characters in length will fail to be cached and an 
IOError will be raised.

What is the expected output? What do you see instead?
Crash along the lines of:

Traceback (most recent call last):
  File "gam.py", line 5863, in <module>
  File "gam.py", line 5011, in doPrintCrosDevices
  File "gam.py", line 376, in callGAPIpages
  File "gam.py", line 331, in callGAPI
  File "oauth2client\util.pyo", line 132, in positional_wrapper
  File "apiclient\http.pyo", line 716, in execute
  File "oauth2client\util.pyo", line 132, in positional_wrapper
  File "oauth2client\client.pyo", line 490, in new_request
  File "httplib2\__init__.pyo", line 1570, in request
  File "httplib2\__init__.pyo", line 1375, in _request
  File "httplib2\__init__.pyo", line 448, in _updateCache
  File "httplib2\__init__.pyo", line 715, in set
IOError: [Errno 2] No such file or directory: 'C:\\Program Files\\gam\\gamcache\
\www.googleapis.com,admin,directory,v1,customer,my_customer,devices,chromeos,quo
taUser=49e4b370af38fe099c10336cbef656235295e57d&pageToken=CPD728ybjbkCEoYBCm73RQ
ek_______3_ef83dvGxsvHz5nMydLGzcac0svOmsf,76a95ebc62884d139bc95722cb6098a5'

What version of the product are you using? On what operating system?
0.8
Windows 7 x64
Python 2.7.5 x64

Please provide any additional information below.
I'd suggest cutting the URL portion of the filename down from a maximum 200 
characters to something more conservative like 100 or 150 to leave more room 
for the cache folder path in the 260 character limit.

The limit could optionally be imposed only on Windows platforms.

Original issue reported on code.google.com by jay@ditoweb.com on 23 Aug 2013 at 2:33

GoogleCodeExporter commented 8 years ago
The better solution would be to provide a Windows specific cache implementation.

Original comment by joe.gregorio@gmail.com on 13 Oct 2013 at 3:12