Closed ariselseng closed 8 years ago
Ouch! Well, obviously, we're missing urllib.quote() somewhere. Care to take a look?
btw, this would solve #25, too.
I can try. But I must admit this is my first python project ;)
Ok, that's cool :) :+1:
Shout out if you have any questions.
I added an escape for urls. It seems to work good. There is another problem though with jottalib not understanding the file info from jotta (after having successfully uploaded the file and rerunned the sync), because of not decoding the url correctly.
Entering dir: /home/cowai/Downloads/test
Ouch. Something's wrong with "/home/cowai/Downloads/test/%2FVolumes%2FMedia%2FiMovie%20Events%2Elocalized%2Farbeidsbenk%2FIMG_4416%2EMOV":
ERROR:root:SAFERUN: Got exception when processing (u'/home/cowai/Downloads/test/%2FVolumes%2FMedia%2FiMovie%20Events%2Elocalized%2Farbeidsbenk%2FIMG_4416%2EMOV', u'/machinename/Downloadtest/test/%2FVolumes%2FMedia%2FiMovie%20Events%2Elocalized%2Farbeidsbenk%2FIMG_4416%2EMOV', <jottalib.JFS.JFS object at 0x7f7dcecae390>)
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/jottacloudclient-0.3.1.post1-py2.7.egg/EGG-INFO/scripts/jottacloudclientscanner.py", line 90, in saferun
File "build/bdist.linux-x86_64/egg/jottacloudclient/jottacloud.py", line 123, in replace_if_changed
jf = JFS.getObject(jottapath)
File "build/bdist.linux-x86_64/egg/jottalib/JFS.py", line 735, in getObject
o = self.get(url, usecache=usecache)
File "build/bdist.linux-x86_64/egg/jottalib/JFS.py", line 723, in get
o = lxml.objectify.fromstring(self.raw(url, usecache=usecache))
File "build/bdist.linux-x86_64/egg/jottalib/JFS.py", line 718, in raw
JFSError.raiseError(o, url)
File "build/bdist.linux-x86_64/egg/jottalib/JFS.py", line 78, in raiseError
raise JFSNotFoundError('%s does not exist (%s)' % (path, e.message))
JFSNotFoundError: /machinename/Downloadtest/test/%2FVolumes%2FMedia%2FiMovie%20Events%2Elocalized%2Farbeidsbenk%2FIMG_4416%2EMOV does not exist (no.jotta.backup.errors.NoSuchPathException)
comparing 1 existing files: [●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●●] 1/1 - 00:00:00
Finished syncing 0 files, with 1 errors (read ./jottacloudclient.log for details)
@havardgulldahl Please test my latest commit. I think it actually works now. I did not find a way to do it with urllib3 though.
There is problems with filenames that have "=" and "?" in their names. Because of how jottalib is coded we need to refactor a bit to get around that. Because we cannot escape/replace = and ? with their escape versions inside JFS.post and JFS.get because functions like delete() in jottacloud.py appends "?dl=true" to the url, which would be escaped as well. So either we need to escape the url in all functions that use JFS.post/JFS.get or we need to send the url params as another parameter to JFS.post/JFS.get. What do you think?
Hm, from what you're saying, adding '?dl=true' after a round of urllib.quote() sounds right. We can't do it in .post()
or .get()
, as you say.
Maybe we should add a method called .path_quoted()
or somesuch to JFSFile
and JFSFolder
and friends, and use that instead of self.path
.
I tested your code, and while it works, I've written some more tests that you have to take a look at, please: https://github.com/havardgulldahl/jottalib/commit/48c42c19bedc065d3980b70e4ff1860978aa9f35
Great stuff so far, @cowai !
Sorry, use this commit instead: 90756360caafe86325b2b8ecd53250466b813d37 (it's in current master)
I will check out the tests tomorrow. Now I need to sleep ;) Btw, checkout my latest master. I actually made a helper function to quote full urls. It works good. Not perfect, but the good thing is that we don't need to rewrite half the code. .post() and .get() is all that is needed to quote the path when they use the new quote function. What do you think?
I am testing current master (9075636). I get JFSNotFoundError: https://www.jotta.no/jfs/USERNAME/Jotta/Archive/testimage.jpg?mode=thumb&ts=WL does not exist (no.jotta.backup.errors.NoSuchPathException) Do I need to have a testimage.jpg somewhere locally? EDIT: figured out I need this file at jotta.
Yes. That would be a bug with the test suite. Thanks
Hi, I just noticed that files with "+" in the the name is interpreted as a space. Next time I sync, it gets deleted again there is no local file with same name ;) "Deleting 1 files from JottaCloud because they no longer exist locally" Maybe we can monkey patch this iwth '.replace("+","%2B")' somwhere. Maybe in JFS.up() and in delete() ?