Open einalex opened 3 years ago
I still get another error though:
Traceback (most recent call last):
File "/home/user/git/projects/Remarkable/zotrm/zotrm/zotrm.py", line 540, in <module>
main(args.verbose, args.landscape, args.dry_run)
File "/home/user/git/projects/Remarkable/zotrm/zotrm/zotrm.py", line 528, in main
backsync_papers(zot, rmapi, config, verbose=verbose, dry_run=dry_run, exclude=sent_papers)
File "/home/user/git/projects/Remarkable/zotrm/zotrm/zotrm.py", line 423, in backsync_papers
pdf_res = add_pdf_to_paper(zot_attach, annotated_files[1], zot, config,
File "/home/user/git/projects/Remarkable/zotrm/zotrm/zotrm.py", line 235, in add_pdf_to_paper
raise Exception("Failed to upload pdf to Zotero", res)
Exception: ('Failed to upload pdf to Zotero', {'success': [{'itemType': 'attachment', 'linkMode': 'imported_file', 'title': 'Goodrich, Schultz - 2007 - Human-Robot Interaction A Survey _remarks.pdf', 'accessDate': '', 'note': '', 'tags': [], 'collections': [], 'relations': {}, 'contentType': '', 'charset': '', 'filename': './Goodrich, Schultz - 2007 - Human-Robot Interaction A Survey _remarks.pdf', 'md5': None, 'mtime': None, 'parentItem': 'IVTQ359Y', 'key': 'T6JWADR7'}], 'failure': [], 'unchanged': []})
this means the check for success fails. it expects the "success" field to contain 0, but it doesn't.
So what happens is that the remark pdf file is added to zotero, but the actual pdf file is not moved to where zotero expects it. This happens even after correcting the check for success.
res = zot.attachment_simple([pdf_file], attachment['data']['parentItem'])
dirname = os.path.join(config['zot_storage_dir'], res["success"][0]["key"])
os.mkdir(dirname)
out_pdf_file = os.path.join(dirname, pdf_file[2:])
shutil.move(pdf_file, out_pdf_file)
``
This does the trick for me, but it might be wrong conceptually. I have no idea why the file isn't put there by the zotero api call.
so, further analysis revealed that the api call uploads the remarks file to zotero's cloud storage even if one is using webdav storage, which leads to the file being inaccessible from the local client and ending up in the wrong location.
Sorry for this bug, I don't use zotero's webdav storage. Could you use the pyzotero api to look at what the attachment metadata looks like for a .pdf file that is already on webdav? That will give a clue on how to replace / add the annotated file.
line 198 should be
res = zot.attachment_simple([pdf_file], attachment['data']['parentItem'])