file.contains, file.contains_regex and file.contains_glob are broken for large files
All of these functions follow the pattern
for each 32kb chunk of the file:
search the chunk for the search string
If the search string straddles two chunks, it will not be found.
so I guess we need to incorporate an overlap here, thanks for the catch, we can get this in!
I thought we were overlapping, ie the initial load would contain more info than subsequent chunk loads.
Initial: 123
Feed it one more chunk: 234
etc...
Pedro Algarvio
----- Reply message ----- De: "Thomas S Hatch" [email protected] Para: "saltstack/salt" [email protected] Assunto: [salt] file.contains, file.contains_regex and file.contains_glob are broken for large files (#3127) Data: qui, Jan 3, 2013 16:40 so I guess we need to incorporate an overlap here, thanks for the catch, we can get this in!
—
Reply to this email directly or view it on GitHub.
well, we can take a look, and leave some comments.
@s0undt3ch - rereading salt/utils/filebuffer.py, you are right, of course. It didn't jump out at me on first reading. Sorry for the noise!
I think the different use of "chunk" in salt/utils/filebuffer.py and salt/modules/file.py threw me. It might be helpful to explicitly document BufferedReader.next as returning a window into the file of up to size max_in_mem which advances by chunk_size on each iteration.
@djs52 I can always be wrong, but in this case, I'm glad I'm not, one less bug ;)