Skip to content

Commit

Permalink
sweep: DIRACGrid#7604 feat (DMS): DataManager.putAndRegister rejects …
Browse files Browse the repository at this point in the history
…too long filename
  • Loading branch information
chaen authored and web-flow committed May 16, 2024
1 parent 8721f51 commit 5d79b87
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 5d79b87

Please sign in to comment.