Skip to content

Commit

Permalink
archiveloop: skip clean when user drives away
Browse files Browse the repository at this point in the history
If the archive server is no longer reachable after archiving ends,
assume the user drove away and skip the cleaning step to avoid the
drive being disconnected from the car while driving.
Also skip cleaning if the last cleaning was less than 5 minutes ago,
to avoid double-cleaning when booting up in wifi range.
  • Loading branch information
marcone committed Dec 22, 2024
1 parent 6f64982 commit 4666821
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion run/archiveloop
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,19 @@ function intersect {
}

function clean_cam_mount {

if [ -e /tmp/last_clean_time ]
then
read -r -d . last < /tmp/last_clean_time
read -r -d . now < /proc/uptime
if (( (now - last) < 300 ))
then
log "skipping cleaning cam mount"
return
fi
fi
cat /proc/uptime > /tmp/last_clean_time

log "cleaning cam mount"
ensure_cam_file_is_mounted

Expand Down Expand Up @@ -615,7 +628,12 @@ function archive_teslacam_clips () {
# overlayfs behavior is undefined if the lower is changed while the overlay is active, so umount first
umount "$overlaymerged"

clean_cam_mount
if archive_is_reachable
then
clean_cam_mount
else
log "Archive not reachable, assuming user drove away, skipping cleaning step"
fi
}

function copy_music_files () {
Expand Down

0 comments on commit 4666821

Please sign in to comment.