Mercurial > dedupe
comparison 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 |
comparison
equal
deleted
inserted
replaced
| 95:7c935d3d5b74 | 96:c7da835ea912 |
|---|---|
| 292 sizes.clear(); | 292 sizes.clear(); |
| 293 mtimes.clear(); | 293 mtimes.clear(); |
| 294 checksums.clear(); | 294 checksums.clear(); |
| 295 } | 295 } |
| 296 | 296 |
| 297 bool SqliteDBLink::commit() | 297 bool SqliteDBLink::commit(const QString& prefix) |
| 298 { | 298 { |
| 299 OperationType last = None; | 299 OperationType last = None; |
| 300 QVariantList paths, sizes, mtimes, hashes; | 300 QVariantList paths, sizes, mtimes, hashes; |
| 301 | 301 |
| 302 foreach(const Operation& operation, operations) { | 302 foreach(const Operation& operation, operations) { |
| 319 if (last != None) { | 319 if (last != None) { |
| 320 executeOperation(paths, sizes, mtimes, hashes, last); | 320 executeOperation(paths, sizes, mtimes, hashes, last); |
| 321 } | 321 } |
| 322 | 322 |
| 323 QSqlQuery whatToUpdate(db); | 323 QSqlQuery whatToUpdate(db); |
| 324 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"); | 324 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"; |
| 325 | 325 if (prefix.isEmpty()) { |
| 326 whatToUpdateQuery = whatToUpdateQuery.arg(""); | |
| 327 } | |
| 328 else { | |
| 329 whatToUpdateQuery = whatToUpdateQuery.arg("AND path LIKE :prefix"); | |
| 330 } | |
| 331 whatToUpdate.prepare(whatToUpdateQuery); | |
| 332 if (!prefix.isEmpty()) { | |
| 333 whatToUpdate.bindValue("prefix", QString("%1%").arg(prefix)); | |
| 334 } | |
| 335 | |
| 326 if (!whatToUpdate.exec()) { | 336 if (!whatToUpdate.exec()) { |
| 327 throw SQLException(whatToUpdate); | 337 throw SQLException(whatToUpdate); |
| 328 } | 338 } |
| 329 | 339 |
| 330 int pathIndex = whatToUpdate.record().indexOf("path"); | 340 int pathIndex = whatToUpdate.record().indexOf("path"); |
