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.
/var/cache
customary? Take a look at the File Hierarchy Standard. Ok, if you think it isn't cache, then/var/tmp
? As far as I know, it's also reasonable to create a separate "dot" directory for your app and put stuff in there./var
is going to be tricky as then it's up to me to (a) keep files for different users separate and (b) somehow create folders there when my app runs as a non-root user. For a system service this would be fine, but for a GUI app it really needs to sit somewhere under$HOME
to avoid both these problems./var/tmp
. Try it and see. As regards (a), just prepend the name of a directory with the name of the user. I.e.username-appname-sometmpstring/
and put files for that user in there.