Motion - Feature Request 2012x 01x 31x 122142

Feature Request: Create snapshot file in a temporary location and then rename() it to avoid reading incomplete image

Description

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.

-- VaclavBlaha - 31 Jan 2012

Follow up

Comments

FeatureRequestForm edit

TopicTitle Create snapshot file in a temporary location and then rename() it to avoid reading incomplete image
FeatureRequestStatus New
SubmittedBy VaclavBlaha
Topic revision: r1 - 31 Jan 2012, VaclavBlaha
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.