# cfml-general


04/01/2022, 6:02 PM
Just throwing an architectural question in the group here. Let's say I have a folder which contains multiple files which need to be processed (this processing can be anything). How would one set this up, taking the following in account: in a multithreaded setup, only one thread may access the file at any given time, processed files should be marked as processed - any means possible, failed files should be marked and possibly queued for future processing, failures should be logged, etc. This is just a glimpse of what would be needed. I already have some thoughts, but I have had some good experiences with asking opinions here. On a side note, no this is not an april fools thing :p.

Scott Bennett

04/01/2022, 6:15 PM
I usually set this kind of thing up (in my usage, this is usually some sort of csv based mass import process for the application) by creating a database table that tracks the files that are in the folder. I usually use a status column in the db to track where it is in the process, and I use named cflocks (where the name is the name of the file or the fileid) to prevent the scheduled tasks that will read the files from processing the same file twice at the same time.
in the status column you can have statuses for things like "queued, processing, failed processing, complete" or whatever you need