havardgulldahl / jottalib

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

remove md5 hash from incomplete files in JFSFileDirList() #88

Closed antonhagg closed 8 years ago

antonhagg commented 8 years ago

When going through the code in the JFSFileDirList class i found that it takes into consideration that an incomplete file doesn't have a size. This is the case for md5 aswell and therefore I think the code should be:

                    else:
                        # an incomplete file
                        t.append(treefile(unicode(file_.attrib['name']),
                                          -1, # incomplete files have no size
                                          unicode(""), # incomplete files have no md5
                                          unicode(file_.attrib['uuid'])
                                          )
                                 )
            self.tree[posixpath.join(path, foldername)] = t

insted of the code:

                    else:
                        # an incomplete file
                        t.append(treefile(unicode(file_.attrib['name']),
                                          -1, # incomplete files have no size
                                          unicode(file_.currentRevision.md5),
                                          unicode(file_.attrib['uuid'])
                                          )
                                 )
            self.tree[posixpath.join(path, foldername)] = t
havardgulldahl commented 8 years ago

@antonhagg Tell me more about your case and the error you're getting. In my tests, incomplete files do have md5 hashes.

I see now that this conclusion is quite naive:

if hasattr(file_, 'currentRevision'): # a normal file

We should really explicitly test for the file's state instead. Maybe you're encountering corrupt files? What's the value of state in those files, do you know?

havardgulldahl commented 8 years ago

@antonhagg Please test the newly commited code in 6c844dd and let me know if it fixes things for you

antonhagg commented 8 years ago

I cant remember, but I think the file had no values at all, just the state incomplete. Could this be linked with #104?

antonhagg commented 8 years ago

I have tried to figure this thing out, and latest commit doesn't return any error: 1c41eaabb6e8c74e660b70a58121017328694f2f

havardgulldahl commented 8 years ago

Thank you for your detective work, @antonhagg, as you see I have used some of your logic in 6c844dd. So I'm considering this as fixed.