From 092d2c5e7ac2bc07e995925e79f940f1cc8c744f Mon Sep 17 00:00:00 2001 From: Fabrice Le Goff <fabrice.le.goff@cern.ch> Date: Fri, 17 Mar 2023 16:53:39 +0100 Subject: [PATCH] added SkipSymlinkFiles --- Configs/configparsertest_modifiedvalues.cfg | 1 + Script/cs/Threads/ManagerThread.py | 4 ++++ Script/cs/Tools/ConfigParser.py | 6 ++++++ UnitTests/ConfigParser_Test.py | 2 ++ 4 files changed, 13 insertions(+) diff --git a/Configs/configparsertest_modifiedvalues.cfg b/Configs/configparsertest_modifiedvalues.cfg index b01eafa..e0aa7a2 100644 --- a/Configs/configparsertest_modifiedvalues.cfg +++ b/Configs/configparsertest_modifiedvalues.cfg @@ -57,6 +57,7 @@ ProblScalingFactor: 1 ProblDelayLimit: 1 MinSizekB: 1 RemoveSmallFiles: True +SkipSymlinkFiles: True DrivenPool: [{'projecttag': 'ptag', 'targetdir': 'altdest', 'eosinstance': 'eosdriven'}] CopyEnabled: True # this one has to be default, other we can't set the others MaxConcurrentCopy: 10 diff --git a/Script/cs/Threads/ManagerThread.py b/Script/cs/Threads/ManagerThread.py index 105ef02..82ae442 100644 --- a/Script/cs/Threads/ManagerThread.py +++ b/Script/cs/Threads/ManagerThread.py @@ -175,6 +175,10 @@ class ManagerThread(threading.Thread): Constants.copying_ext, Constants.problematic_ext): continue + if self.conf.SkipSymlinkFiles and os.path.islink(filename): + self.logger.debug('skipping symlink file: %s', filename) + continue + if filename in self.managedfiles: self.logger.debug('file already managed: %s', filename) continue diff --git a/Script/cs/Tools/ConfigParser.py b/Script/cs/Tools/ConfigParser.py index 53371a4..9c429dd 100644 --- a/Script/cs/Tools/ConfigParser.py +++ b/Script/cs/Tools/ConfigParser.py @@ -335,6 +335,12 @@ class ConfigHolder(object): except AttributeError: self.RemoveSmallFiles = False + # Skip files that are symlinks + try: + self.SkipSymlinkFiles = cfg.SkipSymlinkFiles + except AttributeError: + self.SkipSymlinkFiles = False + # Directory where to copy the Data Files (string) # Keywords from the filename parser can be used here self.CopyDir = cfg.CopyDir diff --git a/UnitTests/ConfigParser_Test.py b/UnitTests/ConfigParser_Test.py index 1a6e496..6666229 100644 --- a/UnitTests/ConfigParser_Test.py +++ b/UnitTests/ConfigParser_Test.py @@ -71,6 +71,7 @@ class TestConfigHolder(unittest.TestCase): self.assert_equal_del('ProblDelayLimit', 36000) self.assert_equal_del('MinSizekB', None) self.assert_equal_del('RemoveSmallFiles', False) + self.assert_equal_del('SkipSymlinkFiles', False) self.assert_equal_del('DrivenPool', []) self.assert_equal_del('CopyEnabled', True) self.assert_equal_del('MaxConcurrentCopy', 1) @@ -179,6 +180,7 @@ class TestConfigHolder(unittest.TestCase): self.assert_equal_del('ProblDelayLimit', 1) self.assert_equal_del('MinSizekB', 1) self.assert_equal_del('RemoveSmallFiles', True) + self.assert_equal_del('SkipSymlinkFiles', True) # DrivenPool is not straightforward to check self.assertEqual(type(self.c.DrivenPool), type([])) -- GitLab