Limit filename length for uploaded files

we have our documents/ folder in an NFS share and sync the folder to our testsystems at night.
we now run into too long paths for some uploaded files. It can also break backup archives.

Our users sometimes upload email files with extremely long filenames.
The upload works but when we make a copy it breaks.

Is there a way to limit the filename length on upload?

In dolibarr itself or a module/custom function?