0

[Similar question posted in Software Engineering but reposted here as was considered a bit off-topic].

My Flask astronomy app includes functionality which implements a multi-step wizard. Step 1 permits the user to upload an astronomical image file (typically 32mb). Step 2 permits the user to specify parameters for an Astropy module to identify potential stars within the image and match them to an online stellar database. Step 3 permits the user to define a series of filters to define the stars of interest and the final Step 4 saves the filtered star data and deletes the uploaded image.

The image uploaded in Step 1 is currently saved in the Flask Instance Folder (in a sub-folder specific to the Current User) and is deleted in Step 4.

However there will be many situations where the file doesn’t get deleted because the wizard never reaches Step 4 (user navigates to another page without cancelling the wizard, they lose their Internet connection, their PC crashes, etc).

So I need a fool-proof way of deleting orphaned uploaded images. I’ve considered a scheduled task that runs periodically and deletes files > n minutes old, but that seems crude.

Is there a better way?

nakb
  • 321
  • 1
  • 3
  • 16
  • How do the steps work, and how does the user navigate to another page? You mean just closes it or goes to another website? – doctorlove Nov 26 '19 at 12:10
  • At present Step 1 is an AJAX upload and subsequent steps are POSTs to the same endpoint (with hidden form field passing the step number and JavaScript showing/hiding the wizard step tabs as required). User isn’t expected to navigate away (they should either cancel or finish the wizard - either of which will cause the uploaded file to be deleted in the endpoint View function) but occasionally they will, or they may just get bored and close the browser. – nakb Nov 26 '19 at 12:19

0 Answers0