mirror of
https://github.com/borgbackup/borg.git
synced 2025-02-20 21:27:32 +00:00
use stat with follow_symlinks=False
should be equivalent to using os.lstat() before.
This commit is contained in:
parent
094376a8ad
commit
efec00b39c
4 changed files with 8 additions and 8 deletions
|
@ -569,7 +569,7 @@ def extract_item(self, item, restore_attrs=True, dry_run=False, stdout=False, sp
|
|||
path = os.path.join(dest, item.path)
|
||||
# Attempt to remove existing files, ignore errors on failure
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
st = os.stat(path, follow_symlinks=False)
|
||||
if stat.S_ISDIR(st.st_mode):
|
||||
os.rmdir(path)
|
||||
else:
|
||||
|
|
|
@ -436,7 +436,7 @@ def create_inner(archive, cache):
|
|||
continue
|
||||
path = os.path.normpath(path)
|
||||
try:
|
||||
st = os.lstat(path)
|
||||
st = os.stat(path, follow_symlinks=False)
|
||||
except OSError as e:
|
||||
self.print_warning('%s: %s', path, e)
|
||||
continue
|
||||
|
@ -498,7 +498,7 @@ def _process(self, archive, cache, matcher, exclude_caches, exclude_if_present,
|
|||
"""
|
||||
if st is None:
|
||||
with backup_io('stat'):
|
||||
st = os.lstat(path)
|
||||
st = os.stat(path, follow_symlinks=False)
|
||||
|
||||
recurse_excluded_dir = False
|
||||
if not matcher.match(path):
|
||||
|
|
|
@ -1758,7 +1758,7 @@ def path(self):
|
|||
|
||||
def stat(self, follow_symlinks=True):
|
||||
assert not follow_symlinks
|
||||
return os.lstat(self.path)
|
||||
return os.stat(self.path, follow_symlinks=follow_symlinks)
|
||||
|
||||
def _check_type(self, type):
|
||||
st = self.stat(False)
|
||||
|
|
|
@ -67,7 +67,7 @@ def are_symlinks_supported():
|
|||
with unopened_tempfile() as filepath:
|
||||
try:
|
||||
os.symlink('somewhere', filepath)
|
||||
if os.lstat(filepath) and os.readlink(filepath) == 'somewhere':
|
||||
if os.stat(filepath, follow_symlinks=False) and os.readlink(filepath) == 'somewhere':
|
||||
return True
|
||||
except OSError:
|
||||
pass
|
||||
|
@ -109,7 +109,7 @@ def is_utime_fully_supported():
|
|||
open(filepath, 'w').close()
|
||||
try:
|
||||
os.utime(filepath, (1000, 2000), follow_symlinks=False)
|
||||
new_stats = os.lstat(filepath)
|
||||
new_stats = os.stat(filepath, follow_symlinks=False)
|
||||
if new_stats.st_atime == 1000 and new_stats.st_mtime == 2000:
|
||||
return True
|
||||
except OSError as err:
|
||||
|
@ -158,8 +158,8 @@ def _assert_dirs_equal_cmp(self, diff, ignore_bsdflags=False, ignore_xattrs=Fals
|
|||
for filename in diff.common:
|
||||
path1 = os.path.join(diff.left, filename)
|
||||
path2 = os.path.join(diff.right, filename)
|
||||
s1 = os.lstat(path1)
|
||||
s2 = os.lstat(path2)
|
||||
s1 = os.stat(path1, follow_symlinks=False)
|
||||
s2 = os.stat(path2, follow_symlinks=False)
|
||||
# Assume path2 is on FUSE if st_dev is different
|
||||
fuse = s1.st_dev != s2.st_dev
|
||||
attrs = ['st_uid', 'st_gid', 'st_rdev']
|
||||
|
|
Loading…
Reference in a new issue