Fix special file detection when broken symlinks are encountered (#596).
This commit is contained in:
parent
e2002b5488
commit
953277a066
4 changed files with 15 additions and 2 deletions
3
NEWS
3
NEWS
|
@ -1,3 +1,6 @@
|
|||
1.7.4.dev0
|
||||
* #596: Fix special file detection when broken symlinks are encountered.
|
||||
|
||||
1.7.3
|
||||
* #357: Add "break-lock" action for removing any repository and cache locks leftover from Borg
|
||||
aborting.
|
||||
|
|
|
@ -229,7 +229,11 @@ def special_file(path):
|
|||
Return whether the given path is a special file (character device, block device, or named pipe
|
||||
/ FIFO).
|
||||
'''
|
||||
try:
|
||||
mode = os.stat(path).st_mode
|
||||
except (FileNotFoundError, OSError):
|
||||
return False
|
||||
|
||||
return stat.S_ISCHR(mode) or stat.S_ISBLK(mode) or stat.S_ISFIFO(mode)
|
||||
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -1,6 +1,6 @@
|
|||
from setuptools import find_packages, setup
|
||||
|
||||
VERSION = '1.7.3'
|
||||
VERSION = '1.7.4.dev0'
|
||||
|
||||
|
||||
setup(
|
||||
|
|
|
@ -338,6 +338,12 @@ def test_special_file_looks_at_file_type(character_device, block_device, fifo, e
|
|||
assert module.special_file('/dev/special') == expected_result
|
||||
|
||||
|
||||
def test_special_file_treats_broken_symlink_as_non_special():
|
||||
flexmock(module.os).should_receive('stat').and_raise(FileNotFoundError)
|
||||
|
||||
assert module.special_file('/broken/symlink') is False
|
||||
|
||||
|
||||
def test_any_parent_directories_treats_parents_as_match():
|
||||
module.any_parent_directories('/foo/bar.txt', ('/foo', '/etc'))
|
||||
|
||||
|
|
Loading…
Reference in a new issue