Allow saving to xml over an existing sqlite3 file and the other way around

A type check on the pre-existing file was preventing this. The type check however
only makes sense when opening files, not when overwriting.
This commit is contained in:
Geert Janssens 2018-07-06 22:00:08 +02:00
parent 49bd9c41c4
commit f067e8328e
2 changed files with 6 additions and 2 deletions

View File

@ -180,7 +180,9 @@ QofSessionImpl::load_backend (std::string access_method) noexcept
continue; continue;
} }
PINFO (" Selected provider %s", prov->provider_name); PINFO (" Selected provider %s", prov->provider_name);
if (!prov->type_check (m_book_id.c_str ())) // Only do a type check when trying to open an existing file
// When saving over an existing file the contents of the original file don't matter
if (!m_creating && !prov->type_check (m_book_id.c_str ()))
{ {
PINFO("Provider, %s, reported not being usable for book, %s.", PINFO("Provider, %s, reported not being usable for book, %s.",
prov->provider_name, m_book_id.c_str ()); prov->provider_name, m_book_id.c_str ());
@ -303,6 +305,7 @@ QofSessionImpl::begin (std::string new_book_id, bool ignore_lock,
destroy_backend (); destroy_backend ();
/* Store the session URL */ /* Store the session URL */
m_book_id = new_book_id; m_book_id = new_book_id;
m_creating = create;
if (filename) if (filename)
load_backend ("file"); load_backend ("file");
else /* access method found, load appropriate backend */ else /* access method found, load appropriate backend */
@ -481,7 +484,7 @@ QofSessionImpl::save (QofPercentageFunc percentage_func) noexcept
} }
else else
{ {
push_error (ERR_BACKEND_NO_HANDLER, "failod to load backend"); push_error (ERR_BACKEND_NO_HANDLER, "failed to load backend");
LEAVE("error -- No backend!"); LEAVE("error -- No backend!");
} }
m_saving = false; m_saving = false;

View File

@ -95,6 +95,7 @@ private:
std::string m_book_id; std::string m_book_id;
bool m_saving; bool m_saving;
bool m_creating;
/* If any book subroutine failed, this records the failure reason /* If any book subroutine failed, this records the failure reason
* (file not found, etc). * (file not found, etc).