mirror of
https://github.com/blakeblackshear/frigate.git
synced 2024-11-21 19:07:46 +01:00
don't overwrite segments that already exist (#3995)
This commit is contained in:
parent
10783fec49
commit
8669c29e3d
@ -276,28 +276,31 @@ class RecordingMaintainer(threading.Thread):
|
|||||||
file_path = os.path.join(directory, file_name)
|
file_path = os.path.join(directory, file_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
start_frame = datetime.datetime.now().timestamp()
|
if not os.path.exists(file_path):
|
||||||
# copy then delete is required when recordings are stored on some network drives
|
start_frame = datetime.datetime.now().timestamp()
|
||||||
shutil.copyfile(cache_path, file_path)
|
# copy then delete is required when recordings are stored on some network drives
|
||||||
logger.debug(
|
shutil.copyfile(cache_path, file_path)
|
||||||
f"Copied {file_path} in {datetime.datetime.now().timestamp()-start_frame} seconds."
|
logger.debug(
|
||||||
)
|
f"Copied {file_path} in {datetime.datetime.now().timestamp()-start_frame} seconds."
|
||||||
os.remove(cache_path)
|
)
|
||||||
|
|
||||||
rand_id = "".join(
|
rand_id = "".join(
|
||||||
random.choices(string.ascii_lowercase + string.digits, k=6)
|
random.choices(string.ascii_lowercase + string.digits, k=6)
|
||||||
)
|
)
|
||||||
Recordings.create(
|
Recordings.create(
|
||||||
id=f"{start_time.timestamp()}-{rand_id}",
|
id=f"{start_time.timestamp()}-{rand_id}",
|
||||||
camera=camera,
|
camera=camera,
|
||||||
path=file_path,
|
path=file_path,
|
||||||
start_time=start_time.timestamp(),
|
start_time=start_time.timestamp(),
|
||||||
end_time=end_time.timestamp(),
|
end_time=end_time.timestamp(),
|
||||||
duration=duration,
|
duration=duration,
|
||||||
motion=motion_count,
|
motion=motion_count,
|
||||||
# TODO: update this to store list of active objects at some point
|
# TODO: update this to store list of active objects at some point
|
||||||
objects=active_count,
|
objects=active_count,
|
||||||
)
|
)
|
||||||
|
else:
|
||||||
|
logger.warning(f"Ignoring segment because {file_path} already exists.")
|
||||||
|
os.remove(cache_path)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"Unable to store recording segment {cache_path}")
|
logger.error(f"Unable to store recording segment {cache_path}")
|
||||||
Path(cache_path).unlink(missing_ok=True)
|
Path(cache_path).unlink(missing_ok=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user