Skip to content

Limpiar las rutas de almacenamiento de AiScan eliminando aiscan_tmp#39

Closed
Copilot wants to merge 1 commit into
mainfrom
copilot/clean-folder-structure
Closed

Limpiar las rutas de almacenamiento de AiScan eliminando aiscan_tmp#39
Copilot wants to merge 1 commit into
mainfrom
copilot/clean-folder-structure

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 18, 2026

Resuelve el #36: los ficheros importados aparecían en la biblioteca bajo la carpeta aiscan_tmp/, cuyo sufijo _tmp daba a entender que eran temporales y podía generar dudas.

Qué hace

Cambia la carpeta de almacenamiento de MyFiles/aiscan_tmp/ a MyFiles/aiscan/, de modo que los adjuntos importados se vean claramente como originados por AiScan, sin el confuso _tmp (a pesar del nombre, esa carpeta siempre fue el almacenamiento real de los adjuntos, no algo temporal).

Cómo

  • Nuevo Lib/StoragePathHelper que centraliza la ruta en un único sitio (constante aiscan) y expone helpers para la ruta absoluta del directorio, la ruta absoluta de un fichero y la ruta relativa que se guarda en AttachedFile->path.
  • Todas las referencias a aiscan_tmp (controlador, AttachmentService, ExtractionService) pasan ahora por el helper — cero rutas hardcodeadas.
  • Los helpers de fichero aplican basename(), saneando el nombre como defensa frente a path traversal.

Notas

  • No migra los adjuntos ya existentes: los ficheros antiguos permanecen en MyFiles/aiscan_tmp/ y sus registros siguen apuntando ahí (siguen funcionando); solo las nuevas importaciones usan aiscan/.
  • Estabiliza el test de fallback de tipo MIME usando contenido determinista en lugar de bytes aleatorios.
  • Tests para StoragePathHelper (ruta limpia + saneamiento de entradas anidadas). Verificado en CI (lint + suite PHPUnit) en PHP 8.1–8.5.

⚠️ Relación con #28 / #29

Este PR solapa y compite con el #29 (issue #28, token myft inválido en JPG/JPEG): ambos modifican Lib/AttachmentService.php y la estrategia de almacenamiento. #29 propone mover los adjuntos a la raíz de MyFiles/ (como el core), lo que arreglaría el token JPG y de paso eliminaría la carpeta aiscan_tmp — haciendo innecesario este PR. Conviene decidir la estrategia (subcarpeta aiscan/ vs. raíz) antes de mezclar cualquiera de los dos.

Closes #36

Copilot AI changed the title [WIP] Refactor storage folder structure to avoid tmp Clean up AiScan storage paths by removing aiscan_tmp May 18, 2026
Copilot AI requested a review from erseco May 18, 2026 18:31
Copilot finished work on behalf of erseco May 18, 2026 18:31
@github-actions
Copy link
Copy Markdown

FacturaScripts Playground Preview

Open this PR in FacturaScripts Playground
Try this PR in your browser

This preview is generated automatically for the copilot/clean-folder-structure branch and loads the plugin directly from the PR branch ZIP in FacturaScripts Playground.

1 similar comment
@github-actions
Copy link
Copy Markdown

FacturaScripts Playground Preview

Open this PR in FacturaScripts Playground
Try this PR in your browser

This preview is generated automatically for the copilot/clean-folder-structure branch and loads the plugin directly from the PR branch ZIP in FacturaScripts Playground.

Copilot finished work on behalf of erseco May 18, 2026 20:06
@erseco erseco force-pushed the copilot/clean-folder-structure branch from c600c7f to 6268504 Compare May 24, 2026 15:47
@erseco erseco marked this pull request as ready for review May 24, 2026 15:47
Replace the confusing 'aiscan_tmp' MyFiles subfolder with 'aiscan' so
imported attachments no longer look temporary in the file library (#36).

- Add StoragePathHelper to centralize the storage path and sanitize file
  names with basename() (defense against path traversal).
- Route every aiscan_tmp reference (controller, AttachmentService,
  ExtractionService) through the helper.
- Stabilize the MIME fallback controller test with deterministic content.
- Complete the LGPL headers on the new files to match the project standard.
@erseco erseco force-pushed the copilot/clean-folder-structure branch from 6268504 to de55df7 Compare May 31, 2026 19:34
@erseco erseco changed the title Clean up AiScan storage paths by removing aiscan_tmp Limpiar las rutas de almacenamiento de AiScan eliminando aiscan_tmp May 31, 2026
@erseco
Copy link
Copy Markdown
Owner

erseco commented May 31, 2026

Se cierra en favor del #29.

Ambos abordan la misma zona (cómo almacena AiScan los adjuntos en MyFiles), pero con enfoques distintos:

Como efecto colateral, el #29 también hace que los adjuntos dejen de aparecer bajo aiscan_tmp/, por lo que cubre también lo que pedía el #36. Optamos por la solución que resuelve el problema de las imágenes. ¡Gracias!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Limpieza en la estructura de carpetas de almacenamiento (evitando el _tmp).

2 participants