dev@locazia: fix indexer
This commit is contained in:
parent
d9e725f7f2
commit
7537dc6a69
|
|
@ -114,27 +114,32 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
|||
StoredContent.hash == item_content_hash_str,
|
||||
# StoredContent.type.like("local%")
|
||||
).first()
|
||||
if encrypted_stored_content:
|
||||
if not encrypted_stored_content.type.startswith("local"):
|
||||
make_log("Indexer", f"Item already indexed, but not local: {item_content_hash_str}", level="error")
|
||||
return platform_found, seqno
|
||||
|
||||
encrypted_stored_content_meta = encrypted_stored_content.meta
|
||||
make_log("Indexer", f"Item already indexed: {item_content_hash_str}", level="debug")
|
||||
encrypted_stored_content.type = "onchain/content"
|
||||
is_duplicate = encrypted_stored_content.type.startswith("onchain") and encrypted_stored_content.onchain_index == item_index
|
||||
if encrypted_stored_content and not is_duplicate:
|
||||
if encrypted_stored_content.type.startswith('local'):
|
||||
encrypted_stored_content.type = "onchain/content" + ("_unknown" if not (encrypted_stored_content.key_id is None) else "")
|
||||
encrypted_stored_content.onchain_index = item_index
|
||||
encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1)
|
||||
if user_wallet_connection:
|
||||
encrypted_stored_content.user_id = user_wallet_connection.user_id
|
||||
|
||||
if encrypted_stored_content_meta != item_metadata_packed:
|
||||
encrypted_stored_content.meta = item_metadata_packed
|
||||
# elif encrypted_stored_content.type.startswith('onchain') and encrypted_stored_content.onchain_index == item_index:
|
||||
# encrypted_stored_content.type = "onchain/content" + ("_unknown" if not (encrypted_stored_content.key_id is None) else "")
|
||||
# encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1)
|
||||
# if user_wallet_connection:
|
||||
# encrypted_stored_content.user_id = user_wallet_connection.user_id
|
||||
else:
|
||||
make_log("Indexer", f"Item already indexed and not local: {item_content_hash_str}", level="error")
|
||||
return platform_found, seqno
|
||||
|
||||
encrypted_stored_content.updated = datetime.now()
|
||||
session.commit()
|
||||
if encrypted_stored_content.meta != item_metadata_packed:
|
||||
encrypted_stored_content.meta = item_metadata_packed
|
||||
|
||||
session.commit()
|
||||
return platform_found, seqno
|
||||
|
||||
item_metadata_packed['copied_from'] = encrypted_stored_content.id if encrypted_stored_content else None
|
||||
|
||||
onchain_stored_content = StoredContent(
|
||||
type="onchain/content_unknown",
|
||||
hash=item_content_hash_str,
|
||||
|
|
|
|||
Loading…
Reference in New Issue