Fix: Ensure export filenames fit within 143-character limit

The eCryptfs filesystem imposes a filename length limit of 143 characters.
This limit still applies on some systems, such as Synology and QNAP NAS devices when using encrypted folders.

When saving documents with long names, Paperless-ngx triggers a warning (`[Errno 36] File name too long`),
but it gracefully falls back to a default or truncated name.

However, the `document_exporter` crashes when encountering such filenames during export.

This change ensures that exported document base names are capped at 120 characters,
leaving room for extensions and suffixes and keeping the total filename length within 143 characters.

Using the document exported with the "--delete" parameter will take care of eventual old files with a long name, if the filesystem supported it.
This commit is contained in:
Antoine Merino
2025-03-07 00:12:45 +01:00
parent cf48f47a8c
commit b0d2cda34a
6 changed files with 61 additions and 5 deletions

View File

@@ -324,9 +324,11 @@ must be provided to import. If this value is lost, the export cannot be imported
!!! warning
If exporting with the file name format, there may be errors due to
your operating system's maximum path lengths. Try adjusting the export
target or consider not using the filename format.
Some operating systems, particularly those using encrypted filesystems
(e.g., some Synology and QNAP NAS devices), impose strict limits
on file name lengths (143 characters).
To ensure compatibility, file names may be truncated to fit within this limit,
meaning the configured filename format may not be fully respected.
### Document importer {#importer}