diff options
Diffstat (limited to 'src/account-server/storage.cpp')
-rw-r--r-- | src/account-server/storage.cpp | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/src/account-server/storage.cpp b/src/account-server/storage.cpp index 6e11f598..39735067 100644 --- a/src/account-server/storage.cpp +++ b/src/account-server/storage.cpp @@ -36,8 +36,7 @@ #include "utils/xml.hpp" #include "utils/sha256.h" -// TODO: make data/items.xml a constant or read it from config file -static const char *DEFAULT_ITEM_FILE = "data/items.xml"; +static const char *DEFAULT_ITEM_FILE = "items.xml"; // defines the supported db version static const char *DB_VERSION_PARAMETER = "database_version"; @@ -1920,24 +1919,18 @@ void Storage::deletePost(Letter *letter) */ void Storage::syncDatabase() { - xmlDocPtr doc = xmlReadFile(DEFAULT_ITEM_FILE, NULL, 0); - if (!doc) - { - LOG_ERROR("Item Manager: Error while parsing item database (items.xml)!"); - return; - } + XML::Document doc(DEFAULT_ITEM_FILE); + xmlNodePtr rootNode = doc.rootNode(); - xmlNodePtr node = xmlDocGetRootElement(doc); - if (!node || !xmlStrEqual(node->name, BAD_CAST "items")) + if (!rootNode || !xmlStrEqual(rootNode->name, BAD_CAST "items")) { - LOG_ERROR("Item Manager:(items.xml) is not a valid database file!"); - xmlFreeDoc(doc); + LOG_ERROR("Item Manager: Error while parsing item database (items.xml)!"); return; } mDb->beginTransaction(); int itmCount = 0; - for (node = node->xmlChildrenNode; node != NULL; node = node->next) + for_each_xml_child_node(node, rootNode) { // Try to load the version of the item database. The version is defined // as subversion tag embedded as XML attribute. So every modification @@ -2024,7 +2017,6 @@ void Storage::syncDatabase() } mDb->commitTransaction(); - xmlFreeDoc(doc); } /** |