Is calling tokio::sleep() with a duration of one week a bad idea?
I’ve created a web app that generates some temporary files during its processing. I’m thinking of creating a worker thread that will delete every file in the temp folder, then call tokio::sleep() with a duration of one week. It’ll run alongside the main application with tokio::select!, and the worker thread will simply never exit under normal circumstances.
Anyways, is there anything wrong with this approach? Is there a better way to schedule tasks like this? I know cron is an option, but my understanding of it is limited. Plus, this app will run in a Docker container, and it seems like Docker + cron is even more of a headache than regular cron.
Edit: For a little more context, this is an app for analyzing x-ray images that’ll be used at the small manufacturing company I work at. Everything will be hosted on local, on-premises servers, and the only user is the guy who runs our x-ray machine lol. Not that I want to excuse bad programming, it’s just that the concerns are a little different when it’s not consumer-facing software. Anyways, once the analysis is generated (which includes some contrast changes and circles around potential defects located by the x-ray), and the results are displayed on a web page, the images are no longer needed. The original image is archived, and there’s a lookup feature that simply re-runs the analysis routine on the raw image and re-generates the result images. All I’d like is to make sure there’s not a glut of these images building up long after they’re needed.