# HG changeset patch # User Tom Fredrik Blenning Klaussen # Date 1382365314 -7200 # Node ID a5788991ca9f09e1180cc3b3ca3f7cc946f082e8 # Parent 7b7a959c993b830a4a5c75b82fecef13a154f160 Refactor lazy update, with one common routine. diff -r 7b7a959c993b -r a5788991ca9f FileDBLink.cpp --- a/FileDBLink.cpp Mon Oct 21 16:20:38 2013 +0200 +++ b/FileDBLink.cpp Mon Oct 21 16:21:54 2013 +0200 @@ -26,6 +26,16 @@ } } +void FileDBLink::addFile(const QString& path, quint64 size, + const QDateTime& lastModified, bool lazy) +{ + QByteArray hash; + //if (!lazy || updateAllWithSize(size)) + if (!lazy) + hash = computeHash(path); + addFile(path, size, lastModified, hash); +} + void FileDBLink::addFile(const QFileInfo& fileinfo, bool lazy) { addFile(fileinfo.absoluteFilePath(), fileinfo.size(), @@ -71,16 +81,6 @@ return false; } -void FileDBLink::addFile(const QString& path, quint64 size, - const QDateTime& lastModified, bool lazy) -{ - QByteArray hash; - // std::cout << path.toStdString() << "::" << lazy << std::endl; - if (!lazy || updateAllWithSize(size)) - hash = computeHash(path); - addFile(path, size, lastModified, hash); -} - void FileDBLink::updateFile(const QFileInfo& fileinfo, bool lazy) { updateFile(fileinfo.absoluteFilePath(), fileinfo.size(), @@ -91,7 +91,8 @@ const QDateTime& lastModified, bool lazy) { QByteArray hash; - if (!lazy || updateAllWithSize(size)) + //if (!lazy || updateAllWithSize(size)) + if (!lazy) hash = computeHash(path); updateFile(path, size, lastModified, hash); }