Mercurial > dedupe
diff SqliteDBLink.cpp @ 96:c7da835ea912
Support for prefix in commit.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Tue, 22 Oct 2013 14:40:08 +0200 |
| parents | 7c935d3d5b74 |
| children | 6c6f3a5f96ea |
line wrap: on
line diff
--- a/SqliteDBLink.cpp Tue Oct 22 14:22:00 2013 +0200 +++ b/SqliteDBLink.cpp Tue Oct 22 14:40:08 2013 +0200 @@ -294,7 +294,7 @@ checksums.clear(); } -bool SqliteDBLink::commit() +bool SqliteDBLink::commit(const QString& prefix) { OperationType last = None; QVariantList paths, sizes, mtimes, hashes; @@ -321,8 +321,18 @@ } QSqlQuery whatToUpdate(db); - whatToUpdate.prepare("SELECT path FROM files WHERE checksum is NULL AND size in (SELECT size FROM files WHERE size <> 0 GROUP BY size HAVING count(*) > 1 ORDER BY SIZE) ORDER BY size"); - + QString whatToUpdateQuery = "SELECT path FROM files WHERE checksum is NULL AND size in (SELECT size FROM files WHERE size <> 0 GROUP BY size HAVING count(*) > 1 ORDER BY SIZE) %1 ORDER BY size"; + if (prefix.isEmpty()) { + whatToUpdateQuery = whatToUpdateQuery.arg(""); + } + else { + whatToUpdateQuery = whatToUpdateQuery.arg("AND path LIKE :prefix"); + } + whatToUpdate.prepare(whatToUpdateQuery); + if (!prefix.isEmpty()) { + whatToUpdate.bindValue("prefix", QString("%1%").arg(prefix)); + } + if (!whatToUpdate.exec()) { throw SQLException(whatToUpdate); }
