summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-10-10 11:16:49 +0200
committerAnton Khirnov <anton@khirnov.net>2023-10-10 11:16:49 +0200
commitbf62039ea856dbe462966eeaf2039dbdde615e93 (patch)
tree93835afa40ffedb4e62b86cb4229ad5d76fb832f
parent81eda8c70280f6eb32962963d344cbf99db2e636 (diff)
Do not call chmod/chown on files for which nothing would be changed.
-rwxr-xr-xperm_offset.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/perm_offset.py b/perm_offset.py
index 20305ad..189728c 100755
--- a/perm_offset.py
+++ b/perm_offset.py
@@ -9,12 +9,19 @@ import sys
def remap_file(fpath, src, dst, count, dry_run):
stat = os.lstat(fpath)
+ do_remap = False
+
uid = stat.st_uid
if uid >= src and uid < src + count:
uid += dst - src
+ do_remap = True
gid = stat.st_gid
if gid >= src and gid < src + count:
gid += dst - src
+ do_remap = True
+
+ if not do_remap:
+ return
mode = S_IMODE(stat.st_mode)