Add support for directories in [files] section
authorClaire Xenia Wolf <claire@clairexen.net>
Sun, 31 Oct 2021 13:43:02 +0000 (14:43 +0100)
committerClaire Xenia Wolf <claire@clairexen.net>
Sun, 31 Oct 2021 13:43:02 +0000 (14:43 +0100)
Signed-off-by: Claire Xenia Wolf <claire@clairexen.net>
sbysrc/sby_core.py

index 979be6f66b25dbb12c573796b1331f18600886ae..78220e50fd3bd55885194e0cde7d2b540e624765 100644 (file)
@@ -20,7 +20,7 @@ import os, re, sys, signal
 if os.name == "posix":
     import resource, fcntl
 import subprocess
-from shutil import copyfile, rmtree
+from shutil import copyfile, copytree, rmtree
 from select import select
 from time import time, localtime, sleep
 
@@ -332,7 +332,10 @@ class SbyJob:
                 os.makedirs(basedir)
 
             self.log(f"Copy '{os.path.abspath(srcfile)}' to '{os.path.abspath(dstfile)}'.")
-            copyfile(srcfile, dstfile)
+            if os.path.isdir(srcfile):
+                copytree(srcfile, dstfile, dirs_exist_ok=True)
+            else:
+                copyfile(srcfile, dstfile)
 
     def handle_str_option(self, option_name, default_value):
         if option_name in self.options: