1
0
spegling av https://github.com/arsenetar/dupeguru.git synced 2026-03-13 03:51:38 +00:00

Also look for errno.EACCES to ensure compatibility with Windows

This commit is contained in:
Luca Falavigna
2024-02-12 11:33:40 +01:00
förälder 5b00de9a43
incheckning f16fce64b7
2 ändrade filer med 4 tillägg och 4 borttagningar

Visa fil

@@ -10,7 +10,7 @@ import logging
import re import re
import os import os
import os.path as op import os.path as op
from errno import EISDIR from errno import EISDIR, EACCES
from xml.etree import ElementTree as ET from xml.etree import ElementTree as ET
from hscommon.jobprogress.job import nulljob from hscommon.jobprogress.job import nulljob
@@ -377,7 +377,7 @@ class Results(Markable):
do_write(outfile) do_write(outfile)
except OSError as e: except OSError as e:
# If our OSError is because dest is already a directory, we want to handle that. # 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) p = str(outfile)
dirname, basename = op.split(p) dirname, basename = op.split(p)
otherfiles = os.listdir(dirname) otherfiles = os.listdir(dirname)

Visa fil

@@ -14,7 +14,7 @@ import re
import os import os
import shutil import shutil
from errno import EISDIR rom errno import EISDIR, EACCES
from pathlib import Path from pathlib import Path
from typing import Callable, List from typing import Callable, List
@@ -76,7 +76,7 @@ def smart_copy(source_path: Path, dest_path: Path) -> None:
try: try:
_smart_move_or_copy(shutil.copy, source_path, dest_path) _smart_move_or_copy(shutil.copy, source_path, dest_path)
except OSError as e: 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) _smart_move_or_copy(shutil.copytree, source_path, dest_path)
else: else:
raise raise