fix convert service
This commit is contained in:
parent
2476d3b3b6
commit
d2ff332490
|
|
@ -65,40 +65,20 @@ async def convert_loop(memory):
|
|||
|
||||
# Для прочих типов сохраняем raw копию и выходим
|
||||
if content_kind == "other":
|
||||
raw_hash = unprocessed_encrypted_content.hash
|
||||
raw_content = StoredContent(
|
||||
type="local/content_raw",
|
||||
hash=raw_hash,
|
||||
user_id=unprocessed_encrypted_content.user_id,
|
||||
filename=unprocessed_encrypted_content.filename,
|
||||
meta={'source': 'raw_copy'},
|
||||
created=datetime.now(),
|
||||
)
|
||||
session.add(raw_content)
|
||||
session.commit()
|
||||
|
||||
# Копируем файл в UPLOADS_DIR
|
||||
dst = os.path.join(UPLOADS_DIR, raw_hash)
|
||||
try:
|
||||
os.remove(dst)
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
shutil.copy2(input_file_path, dst)
|
||||
|
||||
# Обновляем оригинальный объект
|
||||
make_log("ConvertProcess", f"Content {unprocessed_encrypted_content.id} processed. Converted content: {converted_content}", level="info")
|
||||
unprocessed_encrypted_content.btfs_cid = ContentId(
|
||||
version=2, content_hash=b58decode(raw_hash)
|
||||
version=2, content_hash=b58decode(converted_content['high' if content_kind=='video' else 'low'])
|
||||
).serialize_v2()
|
||||
unprocessed_encrypted_content.ipfs_cid = ContentId(
|
||||
version=2, content_hash=b58decode(raw_hash)
|
||||
version=2, content_hash=b58decode(converted_content['low'])
|
||||
).serialize_v2()
|
||||
unprocessed_encrypted_content.meta = {
|
||||
**unprocessed_encrypted_content.meta,
|
||||
'converted_content': {'raw': raw_hash}
|
||||
'converted_content': {
|
||||
option_name: decrypted_content.hash for option_name in ['high', 'low', 'low_preview']
|
||||
}
|
||||
}
|
||||
session.commit()
|
||||
|
||||
make_log("ConvertProcess", f"Raw content saved for {raw_hash}", level="info")
|
||||
return
|
||||
|
||||
# ==== Конвертация для видео или аудио: оригинальная логика ====
|
||||
|
|
|
|||
Loading…
Reference in New Issue