Skip to content

Commit

Permalink
Merge pull request #724 from roflcoopter/feature/available-timespan-s…
Browse files Browse the repository at this point in the history
…afeguard

Available timespan safguard
  • Loading branch information
roflcoopter authored Apr 3, 2024
2 parents a20c630 + ee9183e commit 59d89ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 4 additions & 0 deletions rootfs/etc/cont-init.d/40-set-env-vars
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ fi
export XDG_RUNTIME_DIR=/home/abc
printf "/home/abc" > /var/run/environment/XDG_RUNTIME_DIR

# Set HOME to /home/abc
export HOME=/home/abc
printf "/home/abc" > /var/run/environment/HOME

log_info "*********************** Done *****************************"
8 changes: 3 additions & 5 deletions viseron/components/storage/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from sqlalchemy.sql.functions import coalesce, concat

from viseron.components.storage.models import Files, FilesMeta, Recordings
from viseron.const import CAMERA_SEGMENT_DURATION
from viseron.helpers import utcnow

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -331,7 +332,7 @@ def get_time_period_fragments(
.join(FilesMeta, Files.path == FilesMeta.path)
.where(Files.camera_identifier == camera_identifier)
.where(Files.category == "recorder")
.where(Files.path.endswith(".m4s"))
.where(Files.path.like("%.m4s"))
.where(FilesMeta.meta.comparator.has_key("m3u8")) # type: ignore[attr-defined]
.where(
or_(
Expand All @@ -346,10 +347,7 @@ def get_time_period_fragments(
start >= FilesMeta.orig_ctime,
start
<= FilesMeta.orig_ctime
+ cast(
concat(FilesMeta.meta["m3u8"]["EXTINF"], " sec"),
INTERVAL,
),
+ datetime.timedelta(seconds=CAMERA_SEGMENT_DURATION),
),
)
)
Expand Down

0 comments on commit 59d89ae

Please sign in to comment.