Feature Request: Create snapshot file in a temporary location and then rename() it to avoid reading incomplete image
First of all, thanks for this amazing software. I'm using it to monitor my cats for years and am very happy with it, however, sometimes I manage to read an incomplete snapshot image. I think this could be solved be creating the new snapshot under a temporary path and then using rename() to move it to final location, as rename() is quite atomic while rewriting the file isn't.
Example: My target_dir is /srv/cam/data and my snapshot_filename is ../mem/img (I use a small tmpfs under /srv/cam/mem for snapshots to avoid writing snapshot on disk as this is a flash-based system). Right now, motion saves snapshots to /srv/cam/mem/img.jpg , but it seems the file gets overwritten with every snapshot, with a chance of being read incomplete. I would prefer motion to write new snapshot to a temporary file next to it (e.g. /srv/cam/mem/img.tmp) and then using rename() to move it to it's final position in an atomic way.
If this makes sense and seems acceptable, I think I could also prepare a patch to implement this feature.
- 31 Jan 2012