How do I stop a new file trigger starting before the file is fully there?

Hi

I’m self-hosting my n8n.

I’ve got a local file trigger to start a workflow (it watches for changes within a local folder), but the workflow is triggered as soon as it sees a new file, even if the file hasn’t finished copying to the destination (or is still being written to).

My question is, what is the most appropriate way to combat this? I was wondering if I had any options besides a rudimentary “Wait”

Hey @UnluckyForSome,

I thought we would typically wait for the file to be ready, If that isn’t happening it would be a case of setting up a wait loop. Oddly while a basic solution it is something I had to implement many times about 8 - 10 years ago when I was going with file transfer automation and it always gets the job done.

@UnluckyForSome what OS do you use? I could imagine what your experiencing might not be reproducible on all OSes.

From user experience side, if there’s a change we can make in the node to check for whether the file is fully transferred - sounds like something we’d want to do under-the-hood for users. Not sure if it’s technically possible, but worth an investigation.

1 Like

I’m using Docker on a Synology… I’ve noticed it thinks the file is there while it’s still copying through Windows SMB so I imagine it’s that!

Are you able to transfer the file somewhere and when it’s finished then move it into the directory that n8n is watching?