Skip to content

Commit

Permalink
Fix for loop element change error
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z committed Oct 15, 2024
1 parent aab574d commit 3055b69
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ async def fastapi_lifespan(app: FastAPI):

@fastapi_app.post("/repos/{repo_name}")
async def upload(repo_name: str, file: UploadFile, overwrite: bool = False, ttl_s: int = DEFAULT_TTL_S):
logger.info(f"Uploading file: {file.filename} (content_type: {file.content_type})")
logger.info(f"Uploading file: {file.filename} (content_type: {file.content_type}, ttl_s: {ttl_s}) to repo: {repo_name}")

if file.filename in FILENAME_BLACKLIST:
raise HTTPException(status_code=400, detail=f"Filename {file.filename} is not allowed")
Expand Down Expand Up @@ -313,7 +313,7 @@ def clean(repo_name: str):

try:
ttl_obj = json.loads(ttl_path.read_text())
for file_name, ttl in ttl_obj.items():
for file_name, ttl in ttl_obj.copy().items():
if ttl["expires_at"] < time.time():
file_path = Path(f"/cvmfs/{repo_name}/{file_name}")
if file_path.exists():
Expand All @@ -332,7 +332,7 @@ def clean(repo_name: str):
logger.exception(e)
# abort transaction
subprocess.run(["cvmfs_server", "abort", repo_name, "-f"], check=True)
raise HTTPException(status_code=500, detail="Failed to clean up expired files")
raise HTTPException(status_code=500, detail=f"Failed to clean up expired files: {e}")

# publish transaction
subprocess.run(["cvmfs_server", "publish", repo_name], check=True)
Expand Down

0 comments on commit 3055b69

Please sign in to comment.