From f16fce64b708adcb8aec0880944367af262988c4 Mon Sep 17 00:00:00 2001 From: Luca Falavigna Date: Mon, 12 Feb 2024 11:33:40 +0100 Subject: [PATCH] Also look for errno.EACCES to ensure compatibility with Windows --- core/results.py | 4 ++-- hscommon/conflict.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/results.py b/core/results.py index ddc60f14..b6f11f28 100644 --- a/core/results.py +++ b/core/results.py @@ -10,7 +10,7 @@ import logging import re import os import os.path as op -from errno import EISDIR +from errno import EISDIR, EACCES from xml.etree import ElementTree as ET from hscommon.jobprogress.job import nulljob @@ -377,7 +377,7 @@ class Results(Markable): do_write(outfile) except OSError as e: # If our OSError is because dest is already a directory, we want to handle that. - if e.errno == EISDIR: + if e.errno in (EISDIR, EACCES): p = str(outfile) dirname, basename = op.split(p) otherfiles = os.listdir(dirname) diff --git a/hscommon/conflict.py b/hscommon/conflict.py index 68aa22f0..f20f4885 100644 --- a/hscommon/conflict.py +++ b/hscommon/conflict.py @@ -14,7 +14,7 @@ import re import os import shutil -from errno import EISDIR +rom errno import EISDIR, EACCES from pathlib import Path from typing import Callable, List @@ -76,7 +76,7 @@ def smart_copy(source_path: Path, dest_path: Path) -> None: try: _smart_move_or_copy(shutil.copy, source_path, dest_path) except OSError as e: - if e.errno == EISDIR: # it's a directory + if e.errno in (EISDIR, EACCES): # it's a directory _smart_move_or_copy(shutil.copytree, source_path, dest_path) else: raise