dont stop processing a complex document on the first next_document error: pop level and go on

This commit is contained in:
dockes 2007-01-15 13:06:57 +00:00
parent 71e6591aec
commit e413df1786
2 changed files with 15 additions and 6 deletions

View File

@ -1,5 +1,5 @@
#ifndef lint #ifndef lint
static char rcsid[] = "@(#$Id: internfile.cpp,v 1.23 2006-12-20 14:28:35 dockes Exp $ (C) 2004 J.F.Dockes"; static char rcsid[] = "@(#$Id: internfile.cpp,v 1.24 2007-01-15 13:06:38 dockes Exp $ (C) 2004 J.F.Dockes";
#endif #endif
/* /*
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -266,7 +266,7 @@ bool FileInterner::dijontorcl(Rcl::Doc& doc)
// While we're at it, we also set the mimetype and filename, which are special // While we're at it, we also set the mimetype and filename, which are special
// properties: we want to get them from the topmost doc // properties: we want to get them from the topmost doc
// with an ipath, not the last one which is usually text/plain // with an ipath, not the last one which is usually text/plain
void FileInterner::collectIpathAndMT(Rcl::Doc& doc, string& ipath) void FileInterner::collectIpathAndMT(Rcl::Doc& doc, string& ipath) const
{ {
bool hasipath = false; bool hasipath = false;
@ -307,6 +307,8 @@ void FileInterner::collectIpathAndMT(Rcl::Doc& doc, string& ipath)
// Remove handler from stack. Clean up temp file if needed. // Remove handler from stack. Clean up temp file if needed.
void FileInterner::popHandler() void FileInterner::popHandler()
{ {
if (m_handlers.empty())
return;
int i = m_handlers.size()-1; int i = m_handlers.size()-1;
if (m_tmpflgs[i]) { if (m_tmpflgs[i]) {
m_tempfiles.pop_back(); m_tempfiles.pop_back();
@ -357,9 +359,16 @@ FileInterner::Status FileInterner::internfile(Rcl::Doc& doc, string& ipath)
continue; continue;
} }
// Don't stop on next_document() error. There might be ie an
// error while decoding an attachment, but we still want to
// process the rest of the mbox!
if (!m_handlers.back()->next_document()) { if (!m_handlers.back()->next_document()) {
LOGERR(("FileInterner::internfile: next_document failed\n")); Rcl::Doc doc; string ipath;
return FIError; collectIpathAndMT(doc, ipath);
LOGERR(("FileInterner::internfile: next_document error [%s%s%s]\n",
m_fn.c_str(), ipath.empty()?"":"|", ipath.c_str()));
popHandler();
continue;
} }
// Look at what we've got // Look at what we've got

View File

@ -16,7 +16,7 @@
*/ */
#ifndef _INTERNFILE_H_INCLUDED_ #ifndef _INTERNFILE_H_INCLUDED_
#define _INTERNFILE_H_INCLUDED_ #define _INTERNFILE_H_INCLUDED_
/* @(#$Id: internfile.h,v 1.10 2006-12-19 08:40:50 dockes Exp $ (C) 2004 J.F.Dockes */ /* @(#$Id: internfile.h,v 1.11 2007-01-15 13:06:38 dockes Exp $ (C) 2004 J.F.Dockes */
#include <string> #include <string>
#include <vector> #include <vector>
@ -106,7 +106,7 @@ class FileInterner {
void tmpcleanup(); void tmpcleanup();
bool dijontorcl(Rcl::Doc&); bool dijontorcl(Rcl::Doc&);
void collectIpathAndMT(Rcl::Doc&, string& ipath); void collectIpathAndMT(Rcl::Doc&, string& ipath) const;
bool dataToTempFile(const string& data, const string& mt, string& fn); bool dataToTempFile(const string& data, const string& mt, string& fn);
void popHandler(); void popHandler();
}; };