From 504e391fcf9e58da21aaed29b4b9ea6c45c7ca43 Mon Sep 17 00:00:00 2001 From: Aaron Lichtman Date: Sat, 11 Dec 2021 07:49:09 -0600 Subject: [PATCH] Catch shutil.Error if file is not found Fix #298 --- shallow_backup/utils.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shallow_backup/utils.py b/shallow_backup/utils.py index f8aea97a..5a91d984 100644 --- a/shallow_backup/utils.py +++ b/shallow_backup/utils.py @@ -1,6 +1,7 @@ import os import subprocess as sp from shlex import split +import shutil from shutil import rmtree, copytree from typing import List, Union from .printing import * @@ -186,7 +187,10 @@ def copy_dir_if_valid(source_dir, backup_path): invalid = {".Trash", ".npm", ".cache", ".rvm"} if invalid.intersection(set(os.path.split(source_dir))) != set(): return - copytree(source_dir, backup_path, symlinks=False) + try: + copytree(source_dir, backup_path, symlinks=False) + except shutil.Error: + print_path_red("Error copying:", source_dir) def home_prefix(path):