mirror of
https://github.com/deadc0de6/dotdrop.git
synced 2026-02-10 14:29:15 +00:00
fix mirror rights on update
This commit is contained in:
@@ -13,7 +13,7 @@ import filecmp
|
|||||||
from dotdrop.logger import Logger
|
from dotdrop.logger import Logger
|
||||||
from dotdrop.templategen import Templategen
|
from dotdrop.templategen import Templategen
|
||||||
from dotdrop.utils import patch_ignores, removepath, get_unique_tmp_name, \
|
from dotdrop.utils import patch_ignores, removepath, get_unique_tmp_name, \
|
||||||
write_to_tmpfile, must_ignore, mirror_file_rights
|
write_to_tmpfile, must_ignore, mirror_file_rights, get_file_perm
|
||||||
from dotdrop.exceptions import UndefinedException
|
from dotdrop.exceptions import UndefinedException
|
||||||
|
|
||||||
|
|
||||||
@@ -162,15 +162,20 @@ class Updater:
|
|||||||
def _same_rights(self, left, right):
|
def _same_rights(self, left, right):
|
||||||
"""return True if files have the same modes"""
|
"""return True if files have the same modes"""
|
||||||
try:
|
try:
|
||||||
lefts = os.stat(left)
|
lefts = get_file_perm(left)
|
||||||
rights = os.stat(right)
|
rights = get_file_perm(right)
|
||||||
return lefts.st_mode == rights.st_mode
|
return lefts == rights
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
self.log.err(e)
|
self.log.err(e)
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _mirror_rights(self, src, dst):
|
def _mirror_rights(self, src, dst):
|
||||||
try:
|
try:
|
||||||
|
if self.debug:
|
||||||
|
srcr = get_file_perm(src)
|
||||||
|
dstr = get_file_perm(dst)
|
||||||
|
msg = 'copy rights from {} ({:o}) to {} ({:o})'
|
||||||
|
self.log.dbg(msg.format(src, srcr, dst, dstr))
|
||||||
mirror_file_rights(src, dst)
|
mirror_file_rights(src, dst)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
self.log.err(e)
|
self.log.err(e)
|
||||||
@@ -228,7 +233,9 @@ class Updater:
|
|||||||
# find the differences
|
# find the differences
|
||||||
diff = filecmp.dircmp(path, dtpath, ignore=None)
|
diff = filecmp.dircmp(path, dtpath, ignore=None)
|
||||||
# handle directories diff
|
# handle directories diff
|
||||||
return self._merge_dirs(diff)
|
ret = self._merge_dirs(diff)
|
||||||
|
self._mirror_rights(path, dtpath)
|
||||||
|
return ret
|
||||||
|
|
||||||
def _merge_dirs(self, diff):
|
def _merge_dirs(self, diff):
|
||||||
"""Synchronize directories recursively."""
|
"""Synchronize directories recursively."""
|
||||||
|
|||||||
@@ -300,7 +300,7 @@ def dependencies_met():
|
|||||||
|
|
||||||
def mirror_file_rights(src, dst):
|
def mirror_file_rights(src, dst):
|
||||||
"""mirror file rights of src to dst (can rise exc)"""
|
"""mirror file rights of src to dst (can rise exc)"""
|
||||||
rights = os.stat(src).st_mode
|
rights = get_file_perm(src)
|
||||||
os.chmod(dst, rights)
|
os.chmod(dst, rights)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user