summaryrefslogtreecommitdiffstats
path: root/helper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'helper.cpp')
-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();