diff options
author | Arno <arno@disconnect.de> | 2015-10-24 12:57:21 +0200 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2015-10-24 12:57:21 +0200 |
commit | e1fd385d598e17c77a8b8175b8674b219b45cd8d (patch) | |
tree | 2e9b0606dc7936635967674b222207bd647a17f1 /helper.cpp | |
parent | 25dfbed3a2deceb48ea2b1a6e36585d21de145cc (diff) | |
download | SheMov-e1fd385d598e17c77a8b8175b8674b219b45cd8d.tar.gz SheMov-e1fd385d598e17c77a8b8175b8674b219b45cd8d.tar.bz2 SheMov-e1fd385d598e17c77a8b8175b8674b219b45cd8d.zip |
Make convertArchivefileToPng a transaction
Delete the original file if we converted a pic to PNG, but only if the
database transaction succeeded.
Diffstat (limited to 'helper.cpp')
-rw-r--r-- | helper.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -346,6 +346,7 @@ namespace Helper { retval[3] = dest; //Full path retval[6] = newMd5; //md5sum QSqlDatabase db = QSqlDatabase::database("treedb"); + db.transaction(); int id = data.at(4).toInt(); QSqlQuery q(db); q.prepare("UPDATE pics SET tfilename = :fn, cmd5sum = :md5, isize = :size, tformat = :format WHERE ipicsid = :id"); @@ -356,7 +357,12 @@ namespace Helper { q.bindValue(":id", id); if(q.exec()){ + QFile::remove(data.at(3).toString()); + db.commit(); return retval; + }else{ + QFile::remove(dest); + db.rollback(); } } return PicData(); |