Skip to content

Commit

Permalink
Merge pull request #7617 from DIRACGridBot/cherry-pick-2-03d5fb206-in…
Browse files Browse the repository at this point in the history
…tegration

[sweep:integration] feat (DMS): DataManager.putAndRegister rejects too long filename
  • Loading branch information
chrisburr authored May 16, 2024
2 parents 8721f51 + 5d79b87 commit 3b78e80
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/DIRAC/DataManagementSystem/Client/DataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/DIRAC/DataManagementSystem/Client/FailoverTransfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
temporary replica.
"""

import errno
import time

from DIRAC import S_OK, S_ERROR, gLogger
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions src/DIRAC/DataManagementSystem/Client/__init__.py
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 3b78e80

Please sign in to comment.