dev@locazia: ui fixes
This commit is contained in:
parent
606ef553bc
commit
b4b7a878f4
|
|
@ -28,6 +28,16 @@ async def indexer_loop(platform_found: bool, seqno: int) -> [bool, int]:
|
||||||
|
|
||||||
make_log("Indexer", "Service running", level="debug")
|
make_log("Indexer", "Service running", level="debug")
|
||||||
with db_session() as session:
|
with db_session() as session:
|
||||||
|
content_without_cid = session.query(StoredContent).filter(
|
||||||
|
StoredContent.content_id == None
|
||||||
|
)
|
||||||
|
for target_content in content_without_cid:
|
||||||
|
target_cid = target_content.cid.serialize_v2()
|
||||||
|
make_log("Indexer", f"Content without CID: {target_content.hash}, setting CID: {target_cid}", level="debug")
|
||||||
|
target_content.content_id = target_cid
|
||||||
|
|
||||||
|
session.commit()
|
||||||
|
|
||||||
last_known_index = session.query(StoredContent).filter(
|
last_known_index = session.query(StoredContent).filter(
|
||||||
StoredContent.type == "onchain/content"
|
StoredContent.type == "onchain/content"
|
||||||
).order_by(StoredContent.onchain_index.desc()).first()
|
).order_by(StoredContent.onchain_index.desc()).first()
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ class ContentId:
|
||||||
def safe_onchain_index(self):
|
def safe_onchain_index(self):
|
||||||
return self.onchain_index if (not (self.onchain_index is None) and self.onchain_index >= 0) else None
|
return self.onchain_index if (not (self.onchain_index is None) and self.onchain_index >= 0) else None
|
||||||
|
|
||||||
def serialize_v2(self) -> str:
|
def serialize_v2(self, include_accept_type=False) -> str:
|
||||||
cid_bin = (
|
cid_bin = (
|
||||||
(2).to_bytes(1, 'big') # cid version
|
(2).to_bytes(1, 'big') # cid version
|
||||||
+ self.content_hash
|
+ self.content_hash
|
||||||
|
|
@ -47,7 +47,7 @@ class ContentId:
|
||||||
oi_bin_hex = hex(self.safe_onchain_index)[2:]
|
oi_bin_hex = hex(self.safe_onchain_index)[2:]
|
||||||
oi_bin_len = math.ceil(len(oi_bin_hex) / 2)
|
oi_bin_len = math.ceil(len(oi_bin_hex) / 2)
|
||||||
cid_bin += b'\xb0' + oi_bin_len.to_bytes(1, 'big') + bytes.fromhex(oi_bin_hex)
|
cid_bin += b'\xb0' + oi_bin_len.to_bytes(1, 'big') + bytes.fromhex(oi_bin_hex)
|
||||||
if self.accept_type:
|
if self.accept_type and include_accept_type:
|
||||||
at_bin_len = len(self.accept_type.encode())
|
at_bin_len = len(self.accept_type.encode())
|
||||||
at_bin = string_to_bytes_fixed_size(self.accept_type, at_bin_len)
|
at_bin = string_to_bytes_fixed_size(self.accept_type, at_bin_len)
|
||||||
cid_bin += (
|
cid_bin += (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue