Skip to content

Commit 44c2ff7

Browse files
committed
operations/files.put: fix files.put(mode=True)
Fixes pyinfra-dev#1337 which occurs due a type mismatch between the local file mode returned by get_path_permissions_mode() in api/util.py (str), and the mode data type from the remote file fact (int). Make the change in api/util.py to return an int so the behavior both matches the function's docstring and the implied semantics within put() in operations/files.py.
1 parent fefa4f3 commit 44c2ff7

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

pyinfra/api/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ def get_path_permissions_mode(pathname: str):
425425
"""
426426

427427
mode_octal = oct(stat(pathname).st_mode)
428-
return mode_octal[-3:]
428+
return int(mode_octal[-3:])
429429

430430

431431
def raise_if_bad_type(
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"args": ["somefile.txt", "/home/somefile.txt"],
3+
"kwargs": {
4+
"mode": true
5+
},
6+
"local_files": {
7+
"files": {
8+
"somefile.txt": {
9+
"mode": 644
10+
}
11+
},
12+
"dirs": {}
13+
},
14+
"facts": {
15+
"files.File": {
16+
"path=/home/somefile.txt": {
17+
"mode": 644
18+
}
19+
},
20+
"files.Directory": {
21+
"path=/home": true
22+
},
23+
"files.Sha1File": {
24+
"path=/home/somefile.txt": "ac2cd59a622114712b5b21081763c54bf0caacb8"
25+
}
26+
},
27+
"commands": [],
28+
"noop_description": "file /home/somefile.txt is already uploaded"
29+
}

0 commit comments

Comments
 (0)