Commit a3607d13 authored by Cristiano Urban's avatar Cristiano Urban
Browse files

Merge branch 'testing'

parents 9516b781 12a76ac4
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -46,8 +46,18 @@ class StorePreprocessor(object):
                os.chmod(os.path.join(folder, f), 0o555)

    def start(self):
        # First scan
        [ dirs, files ] = self.scan()        
        
        # Create a .tar for all dirs matching the constraints, if any
        for dir in dirs:
            self.fileGrouper.recursive(self.path + '/' + dir)
        
        # Second scan
        [ dirs, files ] = self.scan()
        timestamp = dt.now().strftime("%Y_%m_%d-%H_%M_%S")
        
        # Case 1: /home/user/store contains both files and dirs
        if files and dirs:
            destPath = self.path + '/' + timestamp
            try:
@@ -60,8 +70,8 @@ class StorePreprocessor(object):
            for dir in dirs:
                srcPath = self.path + '/' + dir                
                shutil.move(srcPath, destPath)
            self.fileGrouper.recursive(destPath)
            self.md5calc.recursive(destPath)
        # Case 2: /home/user/store contains only files    
        elif files and not dirs:
            destPath = self.path + '/' + timestamp
            try:
@@ -71,13 +81,13 @@ class StorePreprocessor(object):
            for file in files:
                srcPath = self.path + '/' + file
                shutil.move(srcPath, destPath)
            self.fileGrouper.recursive(destPath)
            self.md5calc.recursive(destPath)
        # Case 3: /home/user/store contains only dirs
        elif not files and dirs:
            for dir in dirs:
                destPath = self.path + '/' + dir
                self.fileGrouper.recursive(destPath)
                self.md5calc.recursive(destPath)
        # Case 4: /home/user/store is empty
        else:
            sys.exit("The 'store' directory is empty.")