fix(upload): 使用绝对路径和父目录创建,避免 public/songs 不存在导致上传失败
This commit is contained in:
11
app.py
11
app.py
@@ -860,9 +860,14 @@ def upload_file():
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# ディレクトリを作成
|
||||
target_dir = pathlib.Path(os.getenv("TAIKO_WEB_SONGS_DIR", "public/songs")) / generated_id
|
||||
target_dir.mkdir(parents=True,exist_ok=True)
|
||||
base_env = os.getenv("TAIKO_WEB_SONGS_DIR")
|
||||
if base_env:
|
||||
base_dir = pathlib.Path(base_env)
|
||||
else:
|
||||
base_dir = pathlib.Path(__file__).resolve().parent / "public" / "songs"
|
||||
base_dir.mkdir(parents=True, exist_ok=True)
|
||||
target_dir = base_dir / generated_id
|
||||
target_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# TJAを保存
|
||||
(target_dir / "main.tja").write_bytes(tja_data)
|
||||
|
||||
Reference in New Issue
Block a user