diff options
author | Arno <am@disconnect.de> | 2013-08-22 17:37:35 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2013-08-22 17:37:35 +0200 |
commit | c82cdf22f61e79f673e8fdd335b9d9ff4b53969c (patch) | |
tree | 95a564f097543a388a747acec35a48f0ee50a922 | |
parent | 0bc6f9d81ceb45be47d09880c9ec139e2cf371e2 (diff) | |
download | SheMov-c82cdf22f61e79f673e8fdd335b9d9ff4b53969c.tar.gz SheMov-c82cdf22f61e79f673e8fdd335b9d9ff4b53969c.tar.bz2 SheMov-c82cdf22f61e79f673e8fdd335b9d9ff4b53969c.zip |
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.
-rw-r--r-- | newpicsdialog.cpp | 10 |
1 files 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(); } } |