harden memory edits and uploads
This commit is contained in:
@ -157,6 +157,31 @@ class MemoryRepository:
|
||||
).fetchone()
|
||||
return _row_to_dict(row)
|
||||
|
||||
def find_active_resource_by_sha256(
|
||||
self,
|
||||
*,
|
||||
user_id: str,
|
||||
app_id: str,
|
||||
project_id: str,
|
||||
sha256: str,
|
||||
) -> dict[str, Any] | None:
|
||||
with connect(self.db_path) as conn:
|
||||
row = conn.execute(
|
||||
"""
|
||||
SELECT * FROM user_resources
|
||||
WHERE user_id = ?
|
||||
AND app_id = ?
|
||||
AND project_id = ?
|
||||
AND sha256 = ?
|
||||
AND deleted_at IS NULL
|
||||
AND status IN ('ingesting', 'extracted')
|
||||
ORDER BY created_at ASC
|
||||
LIMIT 1
|
||||
""",
|
||||
(user_id, app_id, project_id, sha256),
|
||||
).fetchone()
|
||||
return _row_to_dict(row)
|
||||
|
||||
def list_resources(self, user_id: str) -> list[dict[str, Any]]:
|
||||
with connect(self.db_path) as conn:
|
||||
rows = conn.execute(
|
||||
|
||||
Reference in New Issue
Block a user