summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2015-10-24 12:57:21 +0200
committerArno <arno@disconnect.de>2015-10-24 12:57:21 +0200
commite1fd385d598e17c77a8b8175b8674b219b45cd8d (patch)
tree2e9b0606dc7936635967674b222207bd647a17f1
parent25dfbed3a2deceb48ea2b1a6e36585d21de145cc (diff)
downloadSheMov-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.
-rw-r--r--helper.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/helper.cpp b/helper.cpp
index b913f65..76f637a 100644
--- a/helper.cpp
+++ b/helper.cpp
@@ -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();