Mercurial > dedupe
comparison FileDBLink.cpp @ 91:a5788991ca9f
Refactor lazy update, with one common routine.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Mon, 21 Oct 2013 16:21:54 +0200 |
| parents | af7962f3274b |
| children | f49023c61dac |
comparison
equal
deleted
inserted
replaced
| 90:7b7a959c993b | 91:a5788991ca9f |
|---|---|
| 22 updateFile(fileinfo, lazy); | 22 updateFile(fileinfo, lazy); |
| 23 } | 23 } |
| 24 default: { | 24 default: { |
| 25 } | 25 } |
| 26 } | 26 } |
| 27 } | |
| 28 | |
| 29 void FileDBLink::addFile(const QString& path, quint64 size, | |
| 30 const QDateTime& lastModified, bool lazy) | |
| 31 { | |
| 32 QByteArray hash; | |
| 33 //if (!lazy || updateAllWithSize(size)) | |
| 34 if (!lazy) | |
| 35 hash = computeHash(path); | |
| 36 addFile(path, size, lastModified, hash); | |
| 27 } | 37 } |
| 28 | 38 |
| 29 void FileDBLink::addFile(const QFileInfo& fileinfo, bool lazy) | 39 void FileDBLink::addFile(const QFileInfo& fileinfo, bool lazy) |
| 30 { | 40 { |
| 31 addFile(fileinfo.absoluteFilePath(), fileinfo.size(), | 41 addFile(fileinfo.absoluteFilePath(), fileinfo.size(), |
| 69 return true; | 79 return true; |
| 70 } | 80 } |
| 71 return false; | 81 return false; |
| 72 } | 82 } |
| 73 | 83 |
| 74 void FileDBLink::addFile(const QString& path, quint64 size, | |
| 75 const QDateTime& lastModified, bool lazy) | |
| 76 { | |
| 77 QByteArray hash; | |
| 78 // std::cout << path.toStdString() << "::" << lazy << std::endl; | |
| 79 if (!lazy || updateAllWithSize(size)) | |
| 80 hash = computeHash(path); | |
| 81 addFile(path, size, lastModified, hash); | |
| 82 } | |
| 83 | |
| 84 void FileDBLink::updateFile(const QFileInfo& fileinfo, bool lazy) | 84 void FileDBLink::updateFile(const QFileInfo& fileinfo, bool lazy) |
| 85 { | 85 { |
| 86 updateFile(fileinfo.absoluteFilePath(), fileinfo.size(), | 86 updateFile(fileinfo.absoluteFilePath(), fileinfo.size(), |
| 87 fileinfo.lastModified(), lazy); | 87 fileinfo.lastModified(), lazy); |
| 88 } | 88 } |
| 89 | 89 |
| 90 void FileDBLink::updateFile(const QString& path, quint64 size, | 90 void FileDBLink::updateFile(const QString& path, quint64 size, |
| 91 const QDateTime& lastModified, bool lazy) | 91 const QDateTime& lastModified, bool lazy) |
| 92 { | 92 { |
| 93 QByteArray hash; | 93 QByteArray hash; |
| 94 if (!lazy || updateAllWithSize(size)) | 94 //if (!lazy || updateAllWithSize(size)) |
| 95 if (!lazy) | |
| 95 hash = computeHash(path); | 96 hash = computeHash(path); |
| 96 updateFile(path, size, lastModified, hash); | 97 updateFile(path, size, lastModified, hash); |
| 97 } | 98 } |
| 98 | 99 |
| 99 const QList<FileDBLink::dbinf_ptr_t > | 100 const QList<FileDBLink::dbinf_ptr_t > |
