Use readnext() method to read even 1st chunk of text files to perform appropriate end of chunk truncation to eol. Wont affect uncunked files
This commit is contained in:
parent
aa36cda20c
commit
5cbae3985b
1 changed files with 5 additions and 10 deletions
|
@ -71,16 +71,10 @@ bool MimeHandlerText::set_document_file(const string& mt, const string &fn)
|
|||
ps *= KB;
|
||||
m_paging = true;
|
||||
}
|
||||
// Note: size_t is guaranteed unsigned, so max if ps is -1
|
||||
m_pagesz = size_t(ps);
|
||||
string reason;
|
||||
LOGDEB(("calling file_to_string\n"));
|
||||
// file_to_string() takes pagesz == size_t(-1) to mean read all.
|
||||
if (!file_to_string(fn, m_text, 0, m_pagesz, &reason)) {
|
||||
LOGERR(("MimeHandlerText: can't read file: %s\n", reason.c_str()));
|
||||
if (!readnext())
|
||||
return false;
|
||||
}
|
||||
LOGDEB(("file_to_string OK\n"));
|
||||
m_offs = m_text.length();
|
||||
}
|
||||
if (!m_forPreview) {
|
||||
string md5, xmd5;
|
||||
|
@ -178,7 +172,8 @@ bool MimeHandlerText::readnext()
|
|||
}
|
||||
|
||||
// If possible try to adjust the chunk to end right after a line
|
||||
// Don't do this for the last chunk
|
||||
// Don't do this for the last chunk. Last chunk of exactly the
|
||||
// page size might be unduly split, no big deal
|
||||
if (m_text.length() == m_pagesz) {
|
||||
string::size_type pos = m_text.find_last_of("\n\r");
|
||||
if (pos != string::npos && pos != 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue