.TMP files flagged as on_created events
xx0red opened this issue · comments
When downloading files from Chrome into a monitored folder, while the file downloads it is a .tmp file (per usual) until it finishes fully. The issue I've run into is that watchdog recognizes this .tmp as an event and therefore runs my function which moves the file via sftp. The .tmp is gone once the script gets down to transferring and there fore throws an error, "File couldn't be found". To mitigate this I've attempted to sleep but there's no good point in my code to do so. Help?
It sounds like watchdog is working exactly as intended in this situation - maybe add a simple filter to your function to prevent it from continuing to act on .tmp files?
Probably not proper/idiomatic (I know plain .format is old, at least), but my first pass to test would probably be:
if not ".tmp" in fileName:
sftpTransferFunction()
else:
print("Skipping this file as it appears to be a .tmp file: {}".format(str(fileName)))
Probably broken in a couple ways, and with some fun edge cases, but at least a start (3 weeks late).