Skip to content
This repository has been archived by the owner on Sep 19, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from bemble/fix_delete_download
Browse files Browse the repository at this point in the history
fix(server): fix get model
  • Loading branch information
bemble authored May 17, 2024
2 parents 41407a8 + 284317d commit 8de0254
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion server/holerr/api/routers/downloads.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ async def list_downloads():
@router.delete("/{download_id}", response_model=Download, tags=["Downloads"])
async def delete_download(download_id: str):
session = db.new_session()
download = DownloadRepository(session).get_model(download_id)
download = DownloadRepository(session).get_model(download_id.encode('UTF-8'))
if download is None:
raise HTTPException(status_code=404, detail=f"Download {download_id} not found")
download.to_delete = True
Expand Down
4 changes: 2 additions & 2 deletions server/holerr/database/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ def __init__(self, session: Session, entity: Base):
self.entity = entity

def get_model(self, id: any) -> Base | None:
res = self.session.scalars(select(self.entity).where(self.entity.id == id))
return res.one_or_none()
res = self.get_all_models(self.entity.id == id)
return res[0] if len(res) > 0 else None

def get_all_models(self, conditions=True, options=None) -> list[Base]:
query = select(self.entity).where(conditions)
Expand Down

0 comments on commit 8de0254

Please sign in to comment.