--- /dev/null
+###############################################################################
+# #
+# Pakfire - The IPFire package management system #
+# Copyright (C) 2025 Pakfire development team #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see <http://www.gnu.org/licenses/>. #
+# #
+###############################################################################
+
+import asyncio
+import fastapi
+
+from . import app
+from . import backend
+
+# XXX This endpoint need some ratelimiting applied
+
+@app.get("/buildid/{buildid}/debuginfo", include_in_schema=False)
+async def get(buildid: str) -> fastapi.responses.StreamingResponse:
+ # Fetch the package
+ package = await backend.packages.get_by_buildid(buildid)
+ if not package:
+ raise fastapi.HTTPException(404, "Could not find package providing BuildID %s" % buildid)
+
+ # Fetch the debuginfo
+ file = await package.get_debuginfo(buildid)
+ if not file:
+ raise fastapi.HTTPException(404, "Could not find debuginfo in %s" % package)
+
+ # Create a helper function that will stream the file chunk by chunk
+ async def stream():
+ f = await file.open()
+
+ while True:
+ chunk = await asyncio.to_thread(f.read, 128 * 1024)
+ if not chunk:
+ break
+
+ yield chunk
+
+ # Stream the payload
+ return fastapi.responses.StreamingResponse(
+ stream(), media_type="application/octet-stream")
path = buildid_to_path(buildid)
# Search for the package containing this file
- async for package in self.search_by_filename(path, limit=1):
+ for package in await self.search_by_filename(path, limit=1):
log.debug("Found debuginfo for %s in %s" % (buildid, package))
return package
# Package
- package: "Package" = sqlmodel.Relationship()
+ package: "Package" = sqlmodel.Relationship(
+ sa_relationship_kwargs={ "lazy" : "selectin", },
+ )
# Path