pdf attachment database

edited January 27, 2024
I'm really struggling with Zotero understanding where my attachments are. I want to use it on several computers that share a network folder for attachments. First I put the data folder on the shared drive (against recommendations I know) and it was just too slow and unpredictable so I moved attachments to links and pointed it to a flat shared folder (network folder using zotfile addon). Zotero didn't update the location and can't find any of my files. When I look in the SQLite database there is a table itemAttachments and the path starts with either 'storage:' or 'attachments:' and then the filename (e.g. attachments:filename.pdf). I can't manually change from 'storage:' to 'attachments:' without corrupting something so I'm asking how to manually edit the database to tell Zotero where my files are since it's having such a hard time doing so. One guide mentioned once you correct one file location using locate... when prompted it will automatically apply to others but that is not the case for me.
  • edited January 28, 2024
    The 'attachments:' prefix in front of the linked PDF file name in the sqlite database means that at some point you set a Linked Attachment Base Directory location in Zotero preferences (without that, each linked PDF file's location path is explicitly saved in the database; the 'storage:' prefix is for attachments under local Zotero\storage). That LABD setting tells Zotero where to *look* for linked files (it does not control where new files get stored). You don't actually need a LABD setting unless your linked files are at a different path on different computers. But things will work fine with one, even if the paths are the same on each computer (or even if you only have one computer).

    So it's likely that you set a LABD at some point and now the linked PDFs have been moved somewhere else, but the LABD setting has not been updated. If so, Zotero is looking in the wrong place for them. Set the LABD to where they are now.
  • edited January 28, 2024
    Thanks for your reply. The LABD location is what is confusing me. I have the LABD in Zotero and the 'Location of Files' for ZotFile preferences pointing to the same location. When I click on a file and it says it is not found, I can locate it and then use zotfile to move it and link and I end up with 2 copies in the same folder because the renaming is not exactly the same (Zotero finds it in the LABD folder, moves it to data folder, then zotfile moves it back to LABD folder with slightly different name). The entry in the db, however, changed from 'storage:' to 'attachments:' with minor name adjustments. I'm not sure what else changes in this process so it's not corrupt if I change the database manually. I would like to avoid doing this for all 1k of my references and working with the database directly I would think would be the fastest way to complete it. Is there a way to flag it as a link after I change the 'storage:' to 'attachments:' in the path? there's a sync column and other hash columns that I'm not sure if they are required or not to have a valid entry.
  • edited January 29, 2024
    Firstly I would not be editing the sqlite database directly if you are contemplating that - Zotero devs always advise against that.

    Secondly, while you obviously have some linked files (the ones that *already* have the "attachments:" prefix in the database), the specific problem you describe now seems to be with files that are in *local* Zotero storage (or at least Zotero thinks that is where they are) ...

    If a PDF's file name has the "storage:" prefix in the database at the time Zotero says it can't find it, then it's not a linked file at that stage. Zotero thinks that file is in local Zotero storage (not in Zotfile's Custom Location). If that's what you're dealing with now, forget about the LABD setting just for now - that only concerns linked files (and only where Zotero *looks* for them); and any issues with linked files would be separate.

    Zotero looks for *local* stored PDFs at the location shown under Edit\Preferences\Advanced\Files&Folders\Data Directory location. Click on the Data Directory location button there to show that location, just to confirm that where Zotero thinks it is and where you think it is are really the same thing. That is the folder where Zotero stores the sqlite database, and that folder has child folders that include the storage\ folder hierarchy, under which all locally stored PDFs are stored in arbitrarily-named folders.

    When Zotero shows the message that it can't find a *local* PDF (one with the "storage:" prefix), the message tells you exactly where it is looking for the file. What is that location ? It should correspond to one of the arbitrarily-named folders under Zotero\storage above. Is that PDF file you are looking for in that folder ? If not, where it is ? (and do you know how it got there ?). And is its name exactly the filename that Zotero says it's looking for ?

    Other comments ...
    The messy duplication of files when you try to resolve the above situation is indeed likely due to different renaming rules in place for Zotero and Zotfile; but that is probably secondary to the less-than-ideal way you are trying to resolve things. Hopefully a better way will become apparent once the origin and nature of the current problems is clearer.
    You mention Zotero "moving" PDFs from the LABD. Zotero (not Zotfile) should only be moving PDF files if you use Tools\Manage Attachments\Convert Linked Files to Stored Files. You didn't mention using that, but that would be all that is necessary to move a linked PDF back into local Zotero storage.
    Zotero should always display the link symbol next to PDFs that are linked rather than locally stored. And vice-versa: there should be no link symbol next to PDFs that are in local Zotero storage. Those symbols should match exactly whether a PDF's entry in the database has the storage: or attachments: prefix. Those prefixes should change in the live database when Zotero moves a linked file back to local storage and when Zotfile moves a local file to its linked file location.
    Do you have good backups of the Zotero database folder and local storage folder hierarchy ? It's not clear that you might need to roll back to a previous version, but it's always good to know that you can.
Sign In or Register to comment.