From c82cdf22f61e79f673e8fdd335b9d9ff4b53969c Mon Sep 17 00:00:00 2001 From: Arno Date: Thu, 22 Aug 2013 17:37:35 +0200 Subject: Fix archiving pics Move the pic to archive first. If the filename returned from moveToArchive is different then the file already existed and was mangled with the md5sum. Record the new filename in the db. Theoretically, the same problem exists with archiving movies, but it's very unlikely to happen (I hope). Also, it's way more difficult to untangle. --- newpicsdialog.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/newpicsdialog.cpp b/newpicsdialog.cpp index d4f247c..decdf4d 100644 --- a/newpicsdialog.cpp +++ b/newpicsdialog.cpp @@ -146,7 +146,13 @@ void NewPicsDialog::accept(){ QSqlQuery addMappingQ(mDb); addMappingQ.prepare("INSERT INTO pics_mappings(ipics_id, imappings_parents_id) VALUES((SELECT ipicsid FROM pics where cmd5sum = :md5), :mapid)"); foreach(FileData d, files){ - addFileQ.bindValue(":fn", d.fileName); + QString archivefn = Helper::moveToArchive(d.fullPath, d.md5sum); + if(archivefn.isEmpty()){ + continue; + } + QFileInfo fi(archivefn); + QString fn = fi.fileName(); + addFileQ.bindValue(":fn", fn); addFileQ.bindValue(":md5", d.md5sum); addFileQ.bindValue(":size", d.size); addFileQ.bindValue(":format", d.mimeType); @@ -159,7 +165,7 @@ void NewPicsDialog::accept(){ return; } } - Helper::moveToArchive(d.fullPath, d.md5sum); + mFilesModel->clear(); } } -- cgit v1.2.3-70-g09d2