Typo fixed

This commit is contained in:
Profitroll 2023-01-16 15:32:52 +01:00
parent 7c1db0ce35
commit c09873e92c
1 changed files with 5 additions and 5 deletions

View File

@ -78,7 +78,7 @@ async def saves_get_by_id(id: str, apikey: APIKey = Depends(get_api_key)):
async def saves_download(id: str, save_date: str, apikey: APIKey = Depends(get_api_key)):
if path.exists(path.join(configGet("data", "locations"), "users", apikey, id, save_date)): # type: ignore
save_path = path.join(configGet("data", "locations"), "users", apikey, id, save_date) # type: ignore
return zipfiles([f"{save_path}{sep}{id}.txt", f"{save_path}{sep}SaveGameInfo.txt", f"{save_path}{sep}index.json"], save_name=f"{id}_{save_date}")
return zipfiles([f"{save_path}{sep}{id}.txt", f"{save_path}{sep}SaveGameInfo", f"{save_path}{sep}index.json"], save_name=f"{id}_{save_date}")
else:
return HTTPException(HTTP_404_NOT_FOUND, detail="Could not find save with such id.")
@ -86,18 +86,18 @@ async def saves_download(id: str, save_date: str, apikey: APIKey = Depends(get_a
@app.post("/saves", response_class=UJSONResponse, response_model=StardewSave, description="Upload new save")
async def saves_post(device: str, files: List[UploadFile], apikey: APIKey = Depends(get_api_key)):
error_return = HTTPException(HTTP_406_NOT_ACCEPTABLE, detail="You must provide two files: save file and SaveGameInfo.txt for that save")
error_return = HTTPException(HTTP_406_NOT_ACCEPTABLE, detail="You must provide two files: save file and SaveGameInfo for that save")
if len(files) != 2:
return error_return
if "SaveGameInfo.txt" not in [file.filename for file in files]:
if "SaveGameInfo" not in [file.filename for file in files]:
return error_return
save_info = save_data = save_info_file = save_data_file = None
for file in files:
if file.filename == "SaveGameInfo.txt":
if file.filename == "SaveGameInfo":
save_info_file = await file.read()
save_info = parse(save_info_file.decode("utf-8"))
if "Farmer" not in save_info:
@ -119,7 +119,7 @@ async def saves_post(device: str, files: List[UploadFile], apikey: APIKey = Depe
with open(path.join(configGet("data", "locations"), "users", apikey, save_data["SaveGame"]["uniqueIDForThisGame"], save_date, save_data["SaveGame"]["uniqueIDForThisGame"]+".txt"), "wb") as f: # type: ignore
f.write(save_info_file)
with open(path.join(configGet("data", "locations"), "users", apikey, save_data["SaveGame"]["uniqueIDForThisGame"], save_date, "SaveGameInfo.txt"), "wb") as f: # type: ignore
with open(path.join(configGet("data", "locations"), "users", apikey, save_data["SaveGame"]["uniqueIDForThisGame"], save_date, "SaveGameInfo"), "wb") as f: # type: ignore
f.write(save_data_file)
index = {