Where should an app save working files

configurationdirectory-structurehomexdg

I'm designing a GUI application that works with scanned documents. It allows the scans to be manipulated before they are saved/exported, so it needs to store the data for each scanned page temporarily while it is being worked on.

The amount of data is quite large (often over 100MB even with compression) so storing it in memory is not practical. It's also an onerous job scanning lots of pages, so the scans should be preserved in a "working area" on disk, so that even after rebooting the system the app can be reopened and the previously scanned data will be there ready to continue processing.

I am not quite sure where exactly I should be saving this important, but temporary, data:

  • /tmp/ is bad, because the data should remain after exiting and reopening the app, and even remain after a reboot.
  • $HOME/.config/appname/ isn't really correct, as it's not configuration data I'm saving.
  • $HOME/.local/share/ isn't correct, as the XDG spec says this is for overriding things like icons that are stored in /usr/share/ and there would never be "global" scans put in /usr/share/.
  • $HOME/.cache is close, but this isn't cache data and the user would be most annoyed if it got deleted after they scanned 100 pages and had to scan everything all over again.
  • $HOME/.local/lib/appname doesn't appear in any specs, but could be ok if .local means user-local (lib coming from /var/lib/ use.) If it means local to the machine then it's not a good fit, because the user should be able to log in to a machine with a high-speed scanner, do their scans with this app, log out, then log in on a normal PC and open the app to see what they just scanned – i.e. the data should be preserved across the network on logout, and ~$HOME/.cache needn't be shared among machines so $HOME/.local may not be either – I'm not sure.

So any suggestions on where the most appropriate place to store this kind of data might be?

EDIT: Just to clarify, this is per-user data, and the application is run as a normal user, so putting it in /var/ is probably not correct as you then have to handle multiple users running the application, aside from normal users not having write access there.

Best Answer

I have a GUI application (using wxPython) that imports data from elsewhere before processing two to seven data files to produce a CSV file, a PDF report and, if selected, a number of other report formats. I store the source data files (until archived) and reports in directory structures in $HOME/Documents. This works well but you have to stress to Users that when they create directory names to make them sensitise and not give then nanes like qwerty, fred1, abc123, etc.

Related Question