Cap quality replacement against tracked files only, not total Frigate count
Previously, effective_count and the jobs.py cap check used the total Frigate file count (including manually-added files), so any file a user curated by hand ate into winnow's managed quota. Now: - get_tracked_frigate_file_count() returns len(frigate_files) from the tracker — only files winnow uploaded and reconciled - effective_count in the upload loop uses this tracker count so manually-added files are invisible to the cap - jobs.py capacity check uses len(frigate_files) instead of the live Frigate API count or cached frigate_count - Frigate API call for known_frigate_files_at_start is now only used for the post-upload reconciliation diff, not for cap enforcement Side-effect: fixes audit bug #1 — an unreachable Frigate GET no longer zeroes effective_count and bypasses the cap, because the cap is now read from the always-available local tracker. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -102,6 +102,23 @@ def test_remove_frigate_file_does_not_unmark_asset():
|
||||
assert filter_already_uploaded(["asset-a1"]) == []
|
||||
|
||||
|
||||
def test_get_tracked_frigate_file_count_zero_when_empty():
|
||||
from winnow.upload_tracker import get_tracked_frigate_file_count
|
||||
assert get_tracked_frigate_file_count("Alice") == 0
|
||||
|
||||
|
||||
def test_get_tracked_frigate_file_count_counts_only_mapped():
|
||||
"""Only files explicitly recorded via record_frigate_file count toward the cap."""
|
||||
from winnow.upload_tracker import get_tracked_frigate_file_count, mark_uploaded, record_frigate_file
|
||||
mark_uploaded("asset-a", person_name="Alice")
|
||||
mark_uploaded("asset-b", person_name="Alice")
|
||||
record_frigate_file("Alice", "Alice-1000.webp", "asset-a")
|
||||
# asset-b is uploaded but not yet mapped — does not count
|
||||
assert get_tracked_frigate_file_count("Alice") == 1
|
||||
record_frigate_file("Alice", "Alice-1001.webp", "asset-b")
|
||||
assert get_tracked_frigate_file_count("Alice") == 2
|
||||
|
||||
|
||||
def test_get_lowest_quality_mapped_file_none_when_empty():
|
||||
from winnow.upload_tracker import get_lowest_quality_mapped_file
|
||||
assert get_lowest_quality_mapped_file("Alice") is None
|
||||
|
||||
Reference in New Issue
Block a user