havardgulldahl / jottalib

A library to access files stored at jottacloud.com.
GNU General Public License v3.0
83 stars 19 forks source link

jotta-download - missing part of relative folder string #130

Closed sjurtf closed 1 year ago

sjurtf commented 8 years ago

I'm running the latest code from the master branch to test the jotta-download function.

When trying to download a folder inside /Jotta/Archive/ I'm having some issues with the relative path used.

As seen in the below debug log the error occurs between the "DEBUG:root:absolute folder path" and INFO:root:relative folder path".

'https://www.jottacloud.com' is being chopped and becomes 'tacloud.com' A folder named 'tacloud.com' is being created in the working directory where jotta-download is launched.

Output from runtime using debug -l

Total number of folders to download: 192
INFO:root:topdir: u'/Jotta/Archive'
DEBUG:root:folder: u'/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn,NSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2'
DEBUG:root:absolute folder path  : u'https://www.jottacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn,NSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2'
INFO:root:relative folder path: u'tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn,NSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2'
INFO:root:Entering a new folder: tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn,NSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2
INFO:root:file: TreeFile(name=u'zHTLUUDL1S4z5B7dLtuCZ,Axr,NCVsILDvnvAAGtXmachLVLXVHbcYvZPhKi35-mZZwMAT1PlhW76lWr1kHyL7-S', size=6528325942, md5=u'5083140add2080cea4df73e99d3ddffe', uuid=u'8aa043b0-da90-4528-89f0-ec16df2c6289', state=u'COMPLETED')
INFO:root:Downloading the file from: /Jotta/Archive/tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn,NSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2/zHTLUUDL1S4z5B7dLtuCZ,Axr,NCVsILDvnvAAGtXmachLVLXVHbcYvZPhKi35-mZZwMAT1PlhW76lWr1kHyL7-S
DEBUG:jottalib.JFS:getting url: 'https://www.jottacloud.com/jfs/<email>/Jotta/Archive/tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn%2CNSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2/zHTLUUDL1S4z5B7dLtuCZ%2CAxr%2CNCVsILDvnvAAGtXmachLVLXVHbcYvZPhKi35-mZZwMAT1PlhW76lWr1kHyL7-S', extra_headers=None, params=None
send: 'GET /jfs/<email>/Jotta/Archive/tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn%2CNSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2/zHTLUUDL1S4z5B7dLtuCZ%2CAxr%2CNCVsILDvnvAAGtXmachLVLXVHbcYvZPhKi35-mZZwMAT1PlhW76lWr1kHyL7-S HTTP/1.1\r\nHost: www.jottacloud.com\r\nAccept-Encoding: identity\r\nX-JottaAPIVersion: 2.2\r\nUser-Agent: jottalib 0.5.1 (https://github.com/havardgulldahl/jottalib)\r\nAuthorization: Basic <removed>\r\n\r\n'
reply: 'HTTP/1.1 404 Not Found\r\n'
header: Date: Mon, 19 Sep 2016 22:53:25 GMT
header: Accept-Ranges: bytes
header: X-ID: 037575700
header: Content-Type: text/xml
header: Transfer-Encoding: chunked
header: Server: Jetty(8.1.4.v20120524)
DEBUG:requests.packages.urllib3.connectionpool:"GET /jfs/<email>/Jotta/Archive/tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn%2CNSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2/zHTLUUDL1S4z5B7dLtuCZ%2CAxr%2CNCVsILDvnvAAGtXmachLVLXVHbcYvZPhKi35-mZZwMAT1PlhW76lWr1kHyL7-S HTTP/1.1" 404 None
Traceback (most recent call last):
  File "/usr/local/bin/jotta-download", line 9, in <module>
    load_entry_point('jottalib==0.5.1', 'console_scripts', 'jotta-download')()
  File "/usr/local/lib/python2.7/dist-packages/jottalib/cli.py", line 382, in download
    remote_object = jfs.getObject(abs_path_to_object)
  File "/usr/local/lib/python2.7/dist-packages/jottalib/JFS.py", line 1033, in getObject
    o = self.get(url, params=params) # (.get() will parse this for us)
  File "/usr/local/lib/python2.7/dist-packages/jottalib/JFS.py", line 1002, in get
    content = six.BytesIO(self.raw(url, params=params))
  File "/usr/local/lib/python2.7/dist-packages/jottalib/JFS.py", line 995, in raw
    JFSError.raiseError(o, url)
  File "/usr/local/lib/python2.7/dist-packages/jottalib/JFS.py", line 113, in raiseError
    raise JFSNotFoundError('%s does not exist (%s)' % (path, e.message))
jottalib.JFS.JFSNotFoundError: /Jotta/Archive/tacloud.com/jfs/<user>/Jotta/Archive/<folder>/Zpps0zhOmm7Kn%2CNSuFSeU595St1FgStr3zAGUeNOJa52soeKHcoPZsZuLVtmeJcyFU2/zHTLUUDL1S4z5B7dLtuCZ%2CAxr%2CNCVsILDvnvAAGtXmachLVLXVHbcYvZPhKi35-mZZwMAT1PlhW76lWr1kHyL7-S does not exist (no.jotta.backup.errors.NoSuchPathException)
havardgulldahl commented 8 years ago

Hey, @sjurtf, thanks for the report.

An obvious bug, I am surprised that the tests didn't catch that.

I know you want to keep the folder name hidden, but could you tell us a bit more about how it is structured? Any special characters?

sjurtf commented 8 years ago

The folder names are generated by encfs. I'm not sure how exactly the encfs algorithm to produce the names are, but I've had no issues with folder names when uploading to Jotta using jotta-upload.

The only special characters I've seen are the more normal ones like ',' and '-'.

havardgulldahl commented 8 years ago

So, would you know of a way to reliably trigger this bug? Outside of your own filesystem, I mean.

sjurtf commented 8 years ago

Tested with a regular named folder called test, in the root of Jotta an the same problem occurs.

Total number of folders to download: 1
INFO:root:topdir: u'https://www.jottacloud.com/jfs/<email>/Jotta/Sync'
DEBUG:root:folder: u'/<user>/Jotta/Sync/test'
DEBUG:root:absolute folder path  : u'https://www.jottacloud.com/jfs/<user>/Jotta/Sync/test'
INFO:root:relative folder path: u''
INFO:root:Entering a new folder:
Traceback (most recent call last):
  File "/usr/local/bin/jotta-download", line 9, in <module>
    load_entry_point('jottalib==0.5.1', 'console_scripts', 'jotta-download')()
  File "/usr/local/lib/python2.7/dist-packages/jottalib/cli.py", line 371, in download
    os.makedirs(_rel_folder_path)
  File "/usr/lib/python2.7/os.py", line 157, in makedirs
    mkdir(name, mode)
OSError: [Errno 2] No such file or directory: ''
sjurtf commented 8 years ago

I just fired up a clean ubuntu live usb and installed newest code from github using +git as source for pip. Used the jottalib source code as example filesystem structure. The same bug with relative path being cut of is there.

Total number of folders to download: 6
INFO:root:topdir: u'/Jotta/Archive'
DEBUG:root:folder: u'/<user>/Jotta/Archive/jottalib-master/src/jottalib'
DEBUG:root:absolute folder path  : u'https://www.jottacloud.com/jfs/<user>/Jotta/Archive/jottalib-master/src/jottalib'
INFO:root:relative folder path: u'tacloud.com/jfs/<user>/Jotta/Archive/jottalib-master/src/jottalib'
INFO:root:Entering a new folder: tacloud.com/jfs/<user>/Jotta/Archive/jottalib-master/src/jottalib