fix(upload): 上传后默认启用歌曲并清除 /api/songs 缓存
This commit is contained in:
7
app.py
7
app.py
@@ -848,10 +848,17 @@ def upload_file():
|
|||||||
generated_id = f"{tja_hash}-{music_hash}"
|
generated_id = f"{tja_hash}-{music_hash}"
|
||||||
# MongoDBのデータも作成
|
# MongoDBのデータも作成
|
||||||
db_entry = tja.to_mongo(generated_id, time.time_ns())
|
db_entry = tja.to_mongo(generated_id, time.time_ns())
|
||||||
|
# アップロード直後に有効化
|
||||||
|
db_entry['enabled'] = True
|
||||||
pprint.pprint(db_entry)
|
pprint.pprint(db_entry)
|
||||||
|
|
||||||
# mongoDBにデータをぶち込む
|
# mongoDBにデータをぶち込む
|
||||||
client['taiko']["songs"].insert_one(db_entry)
|
client['taiko']["songs"].insert_one(db_entry)
|
||||||
|
# キャッシュ削除(/api/songs)
|
||||||
|
try:
|
||||||
|
app.cache.delete_memoized(route_api_songs)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# ディレクトリを作成
|
# ディレクトリを作成
|
||||||
target_dir = pathlib.Path(os.getenv("TAIKO_WEB_SONGS_DIR", "public/songs")) / generated_id
|
target_dir = pathlib.Path(os.getenv("TAIKO_WEB_SONGS_DIR", "public/songs")) / generated_id
|
||||||
|
|||||||
Reference in New Issue
Block a user