From c5ed06b70b9a6342bad2b447e9fe0bc26eb4d36f Mon Sep 17 00:00:00 2001
From: Sinisa Veseli <sveseli@aps.anl.gov>
Date: Sun, 18 Sep 2016 04:45:09 +0000
Subject: [PATCH] hashtag file name fix

---
 .../plugins/gridftpFileTransferPlugin.py           | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/src/python/dm/common/processing/plugins/gridftpFileTransferPlugin.py b/src/python/dm/common/processing/plugins/gridftpFileTransferPlugin.py
index acd76c7b..d9c22442 100755
--- a/src/python/dm/common/processing/plugins/gridftpFileTransferPlugin.py
+++ b/src/python/dm/common/processing/plugins/gridftpFileTransferPlugin.py
@@ -28,6 +28,16 @@ class GridftpFileTransferPlugin(FileTransferPlugin):
         self.directoryTransferCommand = directoryTransferCommand 
         self.pluginMustProcessFiles = pluginMustProcessFiles 
 
+    def replaceSpecialCharacters(self, url):
+        replacementMap = {
+	    '#' : '%23',
+	    ' ' : '%20',
+	    '~' : '%7E',
+	}
+	for (original, replacement) in replacementMap.items():
+	    url = url.replace(original,replacement)
+	return url
+
     def getSrcUrl(self, filePath, dataDirectory):
         (scheme, host, port, dirPath) = FtpUtility.parseFtpUrl(dataDirectory, defaultPort=self.DEFAULT_PORT)
         if scheme:
@@ -36,7 +46,7 @@ class GridftpFileTransferPlugin(FileTransferPlugin):
             srcUrl = 'file://%s' % filePath
         else:
             srcUrl = '%s/%s' % (self.src,filePath)
-        return srcUrl
+        return self.replaceSpecialCharacters(srcUrl)
     
     def getDestUrl(self, filePath, dataDirectory, storageHost, storageDirectory):
         (scheme, host, port, dirPath) = FtpUtility.parseFtpUrl(dataDirectory, defaultPort=self.DEFAULT_PORT)
@@ -46,7 +56,7 @@ class GridftpFileTransferPlugin(FileTransferPlugin):
             destUrl = '%s/%s/%s' % (self.dest, dirName, fileName)
         else:
             destUrl = 'sshftp://%s/%s/%s/%s' % (storageHost, storageDirectory, dirName, fileName)
-        return destUrl
+        return self.replaceSpecialCharacters(destUrl)
 
     def checkUploadFilesForProcessing(self, filePathsDict, uploadInfo):
         if not self.pluginMustProcessFiles:
-- 
GitLab