feat: Update docker-compose configuration to use environment variables for sensitive data, enhance testing documentation with new LaTeX files for capacity planning, and refine README for clarity on compilation and testing processes.
This commit is contained in:
@@ -190,24 +190,42 @@ class MinioStorage:
|
||||
return key
|
||||
|
||||
def list_download_files(self, job_id: str, prefix: str | None = None) -> dict:
|
||||
"""Lista PDFs de una corrida (manifest o list_keys)."""
|
||||
"""Lista PDFs de una corrida (manifest o list_keys).
|
||||
|
||||
Si el manifest falta, falla o queda vacío, hace fallback a list_keys
|
||||
bajo el prefijo (cubre varias carpetas NIT planas).
|
||||
"""
|
||||
prefix = prefix or downloads_prefix(job_id)
|
||||
files: List[dict] = []
|
||||
try:
|
||||
raw = self.get_bytes(manifest_key(job_id))
|
||||
payload = json.loads(raw.decode("utf-8"))
|
||||
for key in payload.get("files") or []:
|
||||
files.append(self._file_entry(str(key)))
|
||||
entry = self._file_entry(str(key))
|
||||
if entry is not None:
|
||||
files.append(entry)
|
||||
except Exception:
|
||||
for key in self.list_keys(prefix):
|
||||
if key.endswith("/_manifest.json") or key.endswith("_manifest.json"):
|
||||
continue
|
||||
files.append(self._file_entry(key))
|
||||
files = []
|
||||
|
||||
if not files:
|
||||
files = self._list_pdf_entries(prefix)
|
||||
return {"job_id": job_id, "prefix": prefix, "files": files, "count": len(files)}
|
||||
|
||||
def _list_pdf_entries(self, prefix: str) -> List[dict]:
|
||||
files: List[dict] = []
|
||||
for key in self.list_keys(prefix):
|
||||
entry = self._file_entry(key)
|
||||
if entry is not None:
|
||||
files.append(entry)
|
||||
return files
|
||||
|
||||
@staticmethod
|
||||
def _file_entry(key: str) -> dict:
|
||||
def _file_entry(key: str) -> dict | None:
|
||||
# downloads/{job_id}/{nit}/{radicado}.pdf
|
||||
if key.endswith("/_manifest.json") or key.endswith("_manifest.json"):
|
||||
return None
|
||||
if not key.lower().endswith(".pdf"):
|
||||
return None
|
||||
parts = key.strip("/").split("/")
|
||||
nit = parts[-2] if len(parts) >= 3 else None
|
||||
name = parts[-1] if parts else key
|
||||
|
||||
Reference in New Issue
Block a user