diff --git a/src/DIRAC/DataManagementSystem/Client/DataManager.py b/src/DIRAC/DataManagementSystem/Client/DataManager.py index f414501e0c0..75f51ce972e 100644 --- a/src/DIRAC/DataManagementSystem/Client/DataManager.py +++ b/src/DIRAC/DataManagementSystem/Client/DataManager.py @@ -26,6 +26,7 @@ from DIRAC.Core.Utilities.ReturnValues import returnSingleResult from DIRAC.Core.Security.ProxyInfo import getProxyInfo from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations +from DIRAC.DataManagementSystem.Client import MAX_FILENAME_LENGTH from DIRAC.MonitoringSystem.Client.DataOperationSender import DataOperationSender from DIRAC.DataManagementSystem.Utilities.DMSHelpers import DMSHelpers from DIRAC.Resources.Catalog.FileCatalog import FileCatalog @@ -433,6 +434,9 @@ def putAndRegister(self, lfn, fileName, diracSE, guid=None, path=None, checksum= 'overwrite' removes file from the file catalogue and SE before attempting upload """ + if len(os.path.basename(lfn)) > MAX_FILENAME_LENGTH: + return S_ERROR(errno.ENAMETOOLONG, f"maximum {MAX_FILENAME_LENGTH} characters allowed") + res = self.__hasAccess("addFile", lfn) if not res["OK"]: return res diff --git a/src/DIRAC/DataManagementSystem/Client/FailoverTransfer.py b/src/DIRAC/DataManagementSystem/Client/FailoverTransfer.py index c3fa6e685ae..7f65c1c433d 100644 --- a/src/DIRAC/DataManagementSystem/Client/FailoverTransfer.py +++ b/src/DIRAC/DataManagementSystem/Client/FailoverTransfer.py @@ -16,6 +16,8 @@ temporary replica. """ + +import errno import time from DIRAC import S_OK, S_ERROR, gLogger @@ -107,6 +109,9 @@ def transferAndRegisterFile( break elif cmpError(result, EFCERR): self.log.debug("transferAndRegisterFile: FC unavailable, retry") + elif cmpError(result, errno.ENAMETOOLONG): + self.log.debug(f"transferAndRegisterFile: this file won't be uploaded: {result}") + return result elif retryUpload and len(destinationSEList) == 1: self.log.debug("transferAndRegisterFile: Failed uploading to the only SE, retry") else: diff --git a/src/DIRAC/DataManagementSystem/Client/__init__.py b/src/DIRAC/DataManagementSystem/Client/__init__.py index 6f5707ba432..f06ddfbf90b 100755 --- a/src/DIRAC/DataManagementSystem/Client/__init__.py +++ b/src/DIRAC/DataManagementSystem/Client/__init__.py @@ -1,3 +1,6 @@ """ DIRAC.DataManagementSystem.Client package """ + +#: Maximum number of characters for a filename, this should be the same as the FileName column of the DFC +MAX_FILENAME_LENGTH = 128