Wrong stat object used when updating file permissions #7

Open
opened 2025-11-15 03:44:11 +00:00 by snegov · 0 comments
Owner

Wrong stat object used when updating file permissions

Priority: High
Component: fs.py
Type: Bug

Description

When updating permissions in the rsync() function, the code uses dst_stat.st_mode instead of src_stat.st_mode, which is a logic error.

Location

curateipsum/fs.py:369-372

Current Code

if src_stat.st_mode != dst_stat.st_mode:
    _lg.debug("Rsync, updating permissions: %s", rel_path)
    os.chmod(dst_entry.path, dst_stat.st_mode)  # Should be src_stat!
    yield rel_path, Actions.UPDATE_PERM, ""

Problem

The code compares source and destination modes, determines they're different, but then sets the destination to... the destination's current mode. This is a no-op.

Proposed Solution

if src_stat.st_mode != dst_stat.st_mode:
    _lg.debug("Rsync, updating permissions: %s", rel_path)
    os.chmod(dst_entry.path, src_stat.st_mode)
    yield rel_path, Actions.UPDATE_PERM, ""

Impact

High - Permissions are never updated correctly, defeating the purpose of the rsync functionality.

# Wrong stat object used when updating file permissions **Priority:** High **Component:** fs.py **Type:** Bug ## Description When updating permissions in the `rsync()` function, the code uses `dst_stat.st_mode` instead of `src_stat.st_mode`, which is a logic error. ## Location `curateipsum/fs.py:369-372` ## Current Code ```python if src_stat.st_mode != dst_stat.st_mode: _lg.debug("Rsync, updating permissions: %s", rel_path) os.chmod(dst_entry.path, dst_stat.st_mode) # Should be src_stat! yield rel_path, Actions.UPDATE_PERM, "" ``` ## Problem The code compares source and destination modes, determines they're different, but then sets the destination to... the destination's current mode. This is a no-op. ## Proposed Solution ```python if src_stat.st_mode != dst_stat.st_mode: _lg.debug("Rsync, updating permissions: %s", rel_path) os.chmod(dst_entry.path, src_stat.st_mode) yield rel_path, Actions.UPDATE_PERM, "" ``` ## Impact **High** - Permissions are never updated correctly, defeating the purpose of the rsync functionality.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: snegov/cura-te-ipsum#7
No description provided.