Skip to content

Commit

Permalink
Final webcam archive cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
theyosh committed Nov 2, 2024
1 parent 34841f9 commit e9b3ec0
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion hardware/webcam/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,11 @@ def motion_capture(self, motion_frame="last", motion_threshold=25, motion_area=5
return motion_detected

def clear_archive(self, period=365):
startDate = datetime.now() - timedelta(days=period)
if period <= 0:
return

# Add an extra day here, else you will mis 1 day of archive
startDate = datetime.now() - timedelta(days=period + 1)
logger.debug(f"Webcam {self.name}: Start clearing archive older than {startDate}")
for _ in range(10):
while Path.exists(self.__ARCHIVE_LOCATION.joinpath(self.id, startDate.strftime("%Y/%m/%d"))):
Expand Down

0 comments on commit e9b3ec0

Please sign in to comment.