Space Effficiency: Using Hardlinks to PDFs with Zotero Store Files

My understanding is that Zotero offers two options for connecting PDFs to parent items:

(1) A linked attachment base directory which establishes a location relative to a specific directory (i.e., a dropbox folder) and lets the file exist in the same place on multiple machines

and

(2) A subdirectory called "storage" where copies of PDF files are stored, potentially leading to multiple copies of the same PDF file on the same computer and taking up more hard drive space.

Has anyone tried using Hardlinks instead, so that a single copy of a PDF can exist both in the Zotero storage directory and in the original location without taking up extra hard drive space?
http://www.linuxquestions.org/questions/linux-newbie-8/why-use-hard-links-933471/

What would be the advantages / disadvantages of this approach? Does Zotfile do something like this automatically, or just move the files?
  • edited July 4, 2014
    As far as I know, no one has tried that. It would not work only if the storage folder and the original file were on different disks or partitions. That would potentially leave you with a mixture of files, some that are hard linked, some that are not, depending on where the file was located when it was added to storage.

    (edited to make sense)
  • Thanks. Makes lots of sense. On my main computer, I have a relatively small SSD and a larger secondary HD. So the hardlinks are only good within one disk, not across them. Got that part.

    I've been doing some research before trying this hardlink approach and according to this thread on stack exchange, hardlinks don't work well in OSX for any files that are going to be edited.

    http://superuser.com/questions/302051/how-do-you-create-a-working-hard-link-in-osx

    So if I annotate PDFs, the hardlinks would break and need to be recreated, which would be a hassle.

    What about using aliases? Has anyone tried that? So, for example, the full PDF file either is located within the Zotero storage folder and everything else is an alias, or the Zotero storage folder is full of aliases pointing to files in other folders?
  • The problem there would be with dangling softlinks left behind when their target file is renamed or deleted.
  • also, just as a general note, there is no reason you _have_ to keep copies of the PDFs on your harddisk (though I understand that you may want to). I have all my PDFs in Zotero and just in Zotero, for example.
    If you do want to move instead of copy files into Zotero you can use shift+drag (cmd+drag on Mac).
  • edited July 4, 2014
    I have an existing folder structure for my PDFs that I like--organized by project / paper -- so I can more easily find them and share with editors and co-authors using dropbox.

    I'm trying to avoid having too many duplicate files.

    @ fbennett

    According to the following threads, Symlinks don't work if you rename or delete the target, but aliases still will work:

    http://macs.about.com/od/faq1/f/What-Are-Aliases-Symbolic-Links-And-Hard-Links-In-Mac-Os-X.htm

    http://stackoverflow.com/questions/6311568/are-symbolic-links-and-aliases-the-same-thing-mac-os-x

    http://forums.macrumors.com/showthread.php?t=972404

    It seems like Aliases work better than Symbolic links. Why use Symbolic links?

    Is the issue that Aliases run slower because they need to search for the new filename/location? Or do they not work with some programs?

    Or is it that Aliases take up more space?
    http://apple.stackexchange.com/questions/2991/whats-the-difference-between-alias-and-link

    Any thoughts on whether Aliases or Symlinks would be a better solution, and where the file should go and where the alias / link should go?
  • Those links all pertain to Mac OS X. Zotero has to work across three platforms (Windows, Linux, Mac). I could be wrong, but as far as I know, file aliases as you describe them are not available in Linux. Unsure about Windows.
  • So basically, for Zotero users on a Mac, it should be possible to save a lot of space with Aliases, but his won't work for those using other operating systems?
  • This says that Aliases don't work with programs that use Posix file APIs:

    http://apple.stackexchange.com/questions/2991/whats-the-difference-between-alias-and-link

    "Another difference is that command-line tools (i.e. anything that uses Posix file APIs) won't understand aliases, just symlinks. Both will work for GUI applications. – Gordon Davisson Oct 7 '10 at 19:51"

    Does anyone know if Zotero or important plug ins to Zotero use Posix file APIs?
  • Even if this worked cross-platform, which it doesn't, we have no way of creating hard or soft links in Zotero.
  • Also Msimky, you could recreate your folder organization in Zotero using collections. This would let you allow Zotero to handle the file storage and save space without the headache of hardlinks or double files. Also has the benefit letting you put the same file in multiple project folders without needing to duplicate.
Sign In or Register to comment.