dev@locazia: fix indexer
This commit is contained in:
parent
7537dc6a69
commit
a6c34e732f
|
|
@ -13,6 +13,7 @@ from app.core.logger import make_log
|
||||||
from app.core.models.node_storage import StoredContent
|
from app.core.models.node_storage import StoredContent
|
||||||
from app.core.models.wallet_connection import WalletConnection
|
from app.core.models.wallet_connection import WalletConnection
|
||||||
from app.core.storage import db_session
|
from app.core.storage import db_session
|
||||||
|
import os
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -114,10 +115,13 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
||||||
StoredContent.hash == item_content_hash_str,
|
StoredContent.hash == item_content_hash_str,
|
||||||
# StoredContent.type.like("local%")
|
# StoredContent.type.like("local%")
|
||||||
).first()
|
).first()
|
||||||
is_duplicate = encrypted_stored_content.type.startswith("onchain") and encrypted_stored_content.onchain_index == item_index
|
if encrypted_stored_content:
|
||||||
if encrypted_stored_content and not is_duplicate:
|
is_duplicate = encrypted_stored_content.type.startswith("onchain") \
|
||||||
|
and encrypted_stored_content.onchain_index != item_index
|
||||||
|
if not is_duplicate:
|
||||||
if encrypted_stored_content.type.startswith('local'):
|
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.type = "onchain/content" + (
|
||||||
|
"_unknown" if not (encrypted_stored_content.key_id is None) else "")
|
||||||
encrypted_stored_content.onchain_index = item_index
|
encrypted_stored_content.onchain_index = item_index
|
||||||
encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1)
|
encrypted_stored_content.owner_address = item_owner_address.to_string(1, 1, 1)
|
||||||
if user_wallet_connection:
|
if user_wallet_connection:
|
||||||
|
|
@ -137,8 +141,10 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
||||||
|
|
||||||
session.commit()
|
session.commit()
|
||||||
return platform_found, seqno
|
return platform_found, seqno
|
||||||
|
else:
|
||||||
item_metadata_packed['copied_from'] = encrypted_stored_content.id if encrypted_stored_content else None
|
item_metadata_packed['copied_from'] = encrypted_stored_content.id
|
||||||
|
item_metadata_packed['copied_from_cid'] = encrypted_stored_content.cid.serialize_v2()
|
||||||
|
item_content_hash_str = f"IGNORED_DUPLICATE_{b58encode(os.urandom(30)).decode()}" # check this for vulnerability
|
||||||
|
|
||||||
onchain_stored_content = StoredContent(
|
onchain_stored_content = StoredContent(
|
||||||
type="onchain/content_unknown",
|
type="onchain/content_unknown",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue