fix: close library upload flow and harden image storage
This commit is contained in:
@@ -327,19 +327,19 @@ class DisplayService:
|
||||
if isinstance(content, TemplateContent):
|
||||
values = self.renderer.resolve(content.template, content.data)
|
||||
data = self.renderer.render(content.template, values, content.profile)
|
||||
asset = self.assets.put(
|
||||
with self.assets.creating(
|
||||
data, content.template + ".jpg", "cache" if staging else "generated"
|
||||
)
|
||||
source = {
|
||||
"type": "template",
|
||||
"template": content.template,
|
||||
"data": self.settings.sanitize(values),
|
||||
"profile": content.profile,
|
||||
}
|
||||
self.db.execute(
|
||||
"INSERT OR REPLACE INTO asset_sources VALUES(?,?)",
|
||||
(asset["asset_id"], encode(source)),
|
||||
)
|
||||
) as asset:
|
||||
source = {
|
||||
"type": "template",
|
||||
"template": content.template,
|
||||
"data": self.settings.sanitize(values),
|
||||
"profile": content.profile,
|
||||
}
|
||||
self.db.execute(
|
||||
"INSERT OR REPLACE INTO asset_sources VALUES(?,?)",
|
||||
(asset["asset_id"], encode(source)),
|
||||
)
|
||||
return asset
|
||||
if isinstance(content, PhotoSourceContent):
|
||||
source = self.photo_sources.get(content.source_id)
|
||||
@@ -478,23 +478,23 @@ class DisplayService:
|
||||
"UPDATE operations SET result=? WHERE id=?",
|
||||
(encode({"photo_attempts": attempts}), operation_id),
|
||||
)
|
||||
asset = self.assets.put(
|
||||
with self.assets.creating(
|
||||
rendered, name, "cache" if staging else "images"
|
||||
)
|
||||
self.db.execute(
|
||||
"INSERT OR REPLACE INTO asset_sources VALUES(?,?)",
|
||||
(
|
||||
asset["asset_id"],
|
||||
encode(
|
||||
{
|
||||
"type": "photo_source",
|
||||
"source_id": content.source_id,
|
||||
"item_id": item["id"],
|
||||
"source_path": item.get("source_path"),
|
||||
}
|
||||
) as asset:
|
||||
self.db.execute(
|
||||
"INSERT OR REPLACE INTO asset_sources VALUES(?,?)",
|
||||
(
|
||||
asset["asset_id"],
|
||||
encode(
|
||||
{
|
||||
"type": "photo_source",
|
||||
"source_id": content.source_id,
|
||||
"item_id": item["id"],
|
||||
"source_path": item.get("source_path"),
|
||||
}
|
||||
),
|
||||
),
|
||||
),
|
||||
)
|
||||
)
|
||||
return self.assets.info(asset["asset_id"])
|
||||
raise FlowError(
|
||||
E.INVALID_REQUEST, "No decodable photo found within 5 candidates"
|
||||
|
||||
Reference in New Issue
Block a user