I'm writing a simple program to show pictures, something like gThumb or Eye Of Gnome, just better. I hope. Java, JavaFX, Gradle, Spring Boot - fun!

When it comes to thumbnails persisted on disk, which is an optional feature, how/when should I clean up those files? Some ideas:

Should I randomly delete files to keep at most, say, 1,000 around?

Should I just let the user take care of this, adding files without any limit?

Should I purge the whole directory every once in a while (if the user starts my program)?

I don't think I can make use of the file's creation/modification data, as I need this information to check if the thumbnail matches the original image's data.

@c_otto83 why not add a timestamp to the filename? I’d also say add the option to configure cache size on disk. If you use the XDG spec (I like the platformdirs library for selecting the correct directory), then people can also use other scripts/programs to fine-tune their cache management.

@cameronotsuka Thanks, I'll look into that. Currently, my file names already include a 64 character hash, in addition to tiny rotation information. I might add another hash, and I fear that the file names get too long - but (ab)using the file name might be a valid approach!

Sign in to participate in the conversation

A Mastodon instance aimed at (but not limited to) the cycling community.