Skip to content

include path for sub directories#30

Open
lucas-amiaud wants to merge 1 commit into
masterfrom
evol/include-sub-directories
Open

include path for sub directories#30
lucas-amiaud wants to merge 1 commit into
masterfrom
evol/include-sub-directories

Conversation

@lucas-amiaud
Copy link
Copy Markdown
Member

@lucas-amiaud lucas-amiaud commented Feb 16, 2026

This pull request introduces support for subdirectory paths in file storage, improves file deletion logic, and adds robust path sanitization utilities. It also enhances interfaces and implementations to support these new features, while maintaining backward compatibility. Below are the key changes grouped by theme:

Subdirectory Path Support & Path Sanitization

  • Added a new utility class FilePathSanitizer to securely sanitize and validate file paths, preventing path traversal and other security issues. Comprehensive unit tests for this utility were also added in FilePathSanitizerTest. [1] [2]
  • Extended the FileStorageService interface to support storing and fetching files with subdirectory paths, using file metadata to provide optional path information. New methods add(String, InputStream, FileMetadata) and fetch(String, FileMetadata) were added, along with deleteFiles(List<FileMetadata>).

File Deletion and Metadata Handling Improvements

  • Updated the file deletion logic in FileService to fetch file metadata before deletion, ensuring both file data and metadata are deleted in sync and preventing unreferenced files in storage.
  • Added a new method fetchAll(List<String>) to FileMetadataService and its database implementation, allowing batch retrieval of file metadata by unique names. [1] [2] [3]

Interface and Implementation Enhancements

  • Updated FileStorageDatabaseService to implement the new methods from FileStorageService, handling metadata-aware file operations and delegating appropriately for database storage (which ignores subdirectory paths). [1] [2]
  • Annotated and documented interfaces (FileTypeDatabase, FileTypesProvider) for clarity and improved maintainability. [1] [2]

Logging and Code Clean-up

  • Replaced manual SLF4J logger instantiations with Lombok's @Slf4j annotation in service classes for cleaner and more concise logging. [1] [2] [3]

These changes collectively improve the flexibility, security, and maintainability of the file storage subsystem, especially in environments where organizing files into subdirectories is required.

@lucas-amiaud lucas-amiaud force-pushed the evol/include-sub-directories branch 2 times, most recently from c51dec4 to 57b8b7c Compare February 23, 2026 17:56
@lucas-amiaud lucas-amiaud force-pushed the evol/include-sub-directories branch from 57b8b7c to 9d9b119 Compare February 24, 2026 15:45
* @throws IOException is a file could not be stored
* @throws IOException if a file could not be stored
*/
void add(String fileUniqueName, InputStream fileData) throws IOException;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sur celle là, on pourra la déprécier je pense non ? On s'était dit que ça dégagerait dans la prochaine version majeure (car finalement on garde uniquement cette méthode dans le cas hypothétique où quelqu'un aurait fait une implémentation custom de FileStorageService, ce qui est très improbable).

Pareil pour tous les copains où on ajoute les métadonnées en paramètre

De plus, ça m'ennuie de faire des requêtes aux métadonnées pour les cas où on en a pas besoin. Tu penses qu'on pourrait ajouter une méthode par défaut (par exemple onInstall ou un truc du genre), qui permettrait de refaire remonter à fileService le besoin d'utiliser ou non les métadonnées ? Comme ça, pour la majorité des cas où on n'utilise pas les sous dossiers, alors on garde un fonctionnement "le plus optimisé" possible

Comment on lines +76 to +78
.stream()
.map(FileMetadata.class::cast)
.toList();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C'est hyper bizarre ce traitement

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.

2 participants