Skip to content

Commit

Permalink
feat (DMS): DataManager.putAndRegister rejects too long filename
Browse files Browse the repository at this point in the history
  • Loading branch information
chaen committed May 6, 2024
1 parent 2ed3778 commit 25a34c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/DIRAC/DataManagementSystem/Client/DataManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
This module consists of DataManager and related classes.
"""

# # imports
from datetime import datetime, timedelta
import fnmatch
Expand All @@ -25,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 @@ -432,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
"""

# This should be the same as the FileName column of the DFC
MAX_FILENAME_LENGTH = 128

0 comments on commit 25a34c3

Please sign in to comment.