mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
try mmap first
This commit is contained in:
parent
8aa4f2053e
commit
91a20c07a1
1 changed files with 2 additions and 2 deletions
|
@ -1429,12 +1429,12 @@ def replace(path,
|
|||
with salt.utils.fopen(path,
|
||||
mode='rb',
|
||||
buffering=bufsize) as r_file:
|
||||
if filesize is not 0:
|
||||
try:
|
||||
# mmap throws a ValueError if the file is empty.
|
||||
r_data = mmap.mmap(r_file.fileno(),
|
||||
0,
|
||||
access=mmap.ACCESS_READ)
|
||||
else:
|
||||
except ValueError:
|
||||
# size of file in /proc is 0, but contains data
|
||||
r_data = "".join(r_file)
|
||||
if search_only:
|
||||
|
|
Loading…
Add table
Reference in a new issue