bordaigorl / remy

Remy, an online&offline manager for the reMarkable tablet
GNU General Public License v3.0
279 stars 13 forks source link

Can't connect after importing a PDF #24

Closed alexvlockwood-bes closed 2 years ago

alexvlockwood-bes commented 2 years ago

Running devel branch. I imported a PDF directly into the root (maybe I wasn't supposed to, but I was just clicking around trying to figure out how this works). The upload was successful, but after doing this, I could no longer connect to the reMarkable 2:

[I] Connected to 10.0.11.5
[E] RETRY? ['NoneType' object has no attribute 'append']

I hacked around to get it to print an actual backtrace, and the error was here:

Traceback (most recent call last):
  File "/home/alex/src/remy/remy/gui/app.py", line 120, in retryInit
    raise e
  File "/home/alex/src/remy/remy/gui/app.py", line 335, in run
    index = RemarkableIndex(fsource, progress=self._progress)
  File "/home/alex/src/remy/remy/remarkable/metadata.py", line 400, in __init__
    index[parent].files.append(k)

I was able to make it "work" by doing this, but I have no idea what I'm doing lol so take this more as a hint to where the problem lies than a suggestion on how to fix it

diff --git a/remy/remarkable/metadata.py b/remy/remarkable/metadata.py
index 510f0e0..964d8af 100644
--- a/remy/remarkable/metadata.py
+++ b/remy/remarkable/metadata.py
@@ -505,7 +505,11 @@ class RemarkableIndex:
           if prop.type == FOLDER_TYPE:
             index[parent].folders.append(k)
           elif prop.type == DOCUMENT_TYPE:
-            index[parent].files.append(k)
+            try:
+                index[parent].files.append(k)
+            except AttributeError:
+              print("SKIP", str(index[parent]), str(k))
+              continue
       except KeyError as e:
         raise RemarkableDocumentError("Could not find field {0} in document {1}".format(e,k))

With this in place, everything appears to still be functional. Looks like it's created a PDFDoc entry with no parent and is trying to access its parent.

bordaigorl commented 2 years ago

Oh that looks like a bug, thanks for reporting! Can you be more specific on what lead to this? How did you upload the PDF into the root? Using the drag&drop? (It should totally work, if it doesn't it's a bug) Can you find out the type of the skipped index[parent]?

alexvlockwood-bes commented 2 years ago

I actually used right click -> import, on master before upgrading to devel (sorry, should have been more specific about that - master created the bad state, but both master and devel choke on it).

I'll get back to you on the type - I've already cleared the error out by deleting the file manually from the tablet's UI, I'll try to reproduce it.

bordaigorl commented 2 years ago

Ah it could be a bug of master (will try to find time to merge devel, master is just obsolete at this point but I have to document the changes). Yet I have no idea how index[parent].files can become None...

alexvlockwood-bes commented 2 years ago

I'm kicking myself for deleting the file now, because I can't replicate this at all anymore.

However, I do find that master locks up a lot for me (not just while file operations are happening, it just locks up hard) so it's possible that I killed it while it was in some incomplete state? I don't remember killing it at a time when it appeared to be "working" but could be wrong.

Welp. I guess if can't replicate the error state there's not much you can do here, other than maybe make loading less sensitive to individual objects with unexpected characteristics

bordaigorl commented 2 years ago

By "locks up" you mean it spins? Or crashes? Does devel also "lock up"? Hopefully devel is better behaved 😅

alexvlockwood-bes commented 2 years ago

Totally frozen UI and unresponsive to everything including a ctrl-C on the command line, have to kill -9

yes, I have not had that on devel :) devel is very well behaved