mirror of
https://github.com/FAUSheppy/tmnf-replay-server.git
synced 2026-04-26 22:12:28 +02:00
fix: handle Gbx error & better s3 naming scheme
This commit is contained in:
@@ -9,6 +9,7 @@ import json
|
||||
import datetime
|
||||
|
||||
from pygbx import Gbx, GbxType
|
||||
import pygbx
|
||||
import tm2020parser
|
||||
import notifications
|
||||
|
||||
@@ -541,7 +542,7 @@ def upload():
|
||||
try:
|
||||
replay = replay_from_path(tmp_path, uploader=uploader)
|
||||
|
||||
new_basename = f"{replay.uploader}_{replay.filehash}_{fname}"
|
||||
new_basename = f"{replay.filehash}"
|
||||
fullpath = os.path.join("uploads", new_basename)
|
||||
|
||||
os.rename(tmp_path, fullpath)
|
||||
@@ -549,8 +550,7 @@ def upload():
|
||||
replay.filepath = fullpath
|
||||
|
||||
if s3_enabled():
|
||||
s3_key = upload_to_s3(fullpath, replay)
|
||||
replay.filepath = s3_key
|
||||
s3_key = upload_to_s3(new_basename, replay)
|
||||
os.remove(fullpath)
|
||||
|
||||
db.session.add(replay)
|
||||
@@ -561,6 +561,9 @@ def upload():
|
||||
except ValueError as e:
|
||||
results.append((fname, str(e)))
|
||||
continue
|
||||
except pygbx.Gbx as e:
|
||||
print(f"Failed to load Replay: {e}")
|
||||
continue
|
||||
|
||||
except sqlalchemy.exc.IntegrityError as e:
|
||||
results.append((fname, str(e.args)))
|
||||
|
||||
Reference in New Issue
Block a user