Keep manual redisplays separate from random task cloud heads
This commit is contained in:
@@ -12,14 +12,28 @@ class CloudLibrary:
|
||||
self.checked = 0.0
|
||||
|
||||
def register(self, device_id, image_id, asset_id, operation_id):
|
||||
meta = self.service.assets.info(asset_id)
|
||||
operation = self.db.one(
|
||||
"SELECT payload FROM operations WHERE id=?", (operation_id,)
|
||||
)
|
||||
payload = json.loads(operation["payload"])
|
||||
content = payload.get("content", {})
|
||||
job = self.db.one(
|
||||
"SELECT job_id FROM job_runs WHERE operation_id=?", (operation_id,)
|
||||
)
|
||||
job_id = (
|
||||
job["job_id"]
|
||||
if job
|
||||
and content.get("type") == "photo_source"
|
||||
and content.get("item_id") is None
|
||||
else None
|
||||
)
|
||||
self.db.execute(
|
||||
"INSERT INTO managed_cloud_uploads VALUES(?,?,?,?,?,?,NULL,NULL)",
|
||||
(
|
||||
device_id,
|
||||
image_id,
|
||||
asset_id,
|
||||
meta.get("job_id"),
|
||||
job_id,
|
||||
operation_id,
|
||||
datetime.now(UTC).isoformat(),
|
||||
),
|
||||
|
||||
@@ -144,3 +144,27 @@ def test_clear_cloud_requires_confirmation_and_clears_current(client, service):
|
||||
for _ in range(before):
|
||||
assert service.process_one()
|
||||
assert not service.registry.get("living-room").images()
|
||||
|
||||
|
||||
def test_manual_display_does_not_replace_task_head(client, service, settings):
|
||||
setup_photos(service, settings)
|
||||
job = make_job(client, "A")
|
||||
first, asset = run(client, service, job)
|
||||
second, _ = run(client, service, job)
|
||||
client.put(f"/api/v1/assets/{asset}/star", json={"starred": True})
|
||||
response = client.post(
|
||||
"/api/v1/display", json={"content": {"type": "image", "asset_id": asset}}
|
||||
)
|
||||
service.process_one()
|
||||
service.sync()
|
||||
op = client.get("/api/v1/operations/" + response.json()["operation_id"]).json()
|
||||
row = service.db.one(
|
||||
"SELECT job_id FROM managed_cloud_uploads WHERE image_id=?",
|
||||
(op["result"]["image_id"],),
|
||||
)
|
||||
assert row["job_id"] is None
|
||||
assert service.cloud_library.retained(
|
||||
service.db.one(
|
||||
"SELECT * FROM managed_cloud_uploads WHERE image_id=?", (second,)
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user