[SOLVED] Preventing "orphaned" files - How would you handle it?

I think I’ve got a workable solution!

Instead of doing so when the “save” button is clicked, use the “input has changed” action on an uploader element (file or image) to immediately flag the file as orphaned upon upload (add it to an “orphaned files” list). Then, during the “save” operation AFTER the “Thing” has been created, remove the file from that list.

This should eliminate the need for a “master list” of ALL files, and it should improve the performance of the garbage collection operation, since the list will be MUCH smaller - i.e. only the [relatively few] files that have been orphaned.

I’ll be testing this out, but does anyone see any reason why this wouldn’t work?

6 Likes