[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdelibs/kioslave/http
From:       Andreas Hartmetz <ahartmetz () gmail ! com>
Date:       2010-01-13 21:57:15
Message-ID: 1263419835.475641.10626.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 1074338 by ahartmetz:

- Fix wrong read check in Scoreboard constructor, so now the data will
  actually be loaded. This might give the impression that the whole thing was
  undertested, which is only partially true. I watched a lot of debug output :)
  Summary: It really works now.
- Remove outdated comment and noisy debug messages
- If during cleaning we read a cache file from disk because it wasn't in the
  scoreboard, add it to the scoreboard. Ideally we'd write out the complete
  scoreboard on termination, but how?


 M  +13 -7     http_cache_cleaner.cpp  


--- trunk/KDE/kdelibs/kioslave/http/http_cache_cleaner.cpp #1074337:1074338
@@ -330,6 +330,7 @@
         }
         return memcmp(m_index, other.m_index, sizeof(m_index)) == 0;
     }
+
 private:
     explicit CacheIndex(const QByteArray &index)
     {
@@ -411,7 +412,7 @@
         while (true) {
             QByteArray baIndex = sboard.read(ScoreboardEntry::indexSize);
             QByteArray baRest = sboard.read(ScoreboardEntry::size - ScoreboardEntry::indexSize);
-            if (baIndex.size() + baRest.size() != ScoreboardEntry::indexSize) {
+            if (baIndex.size() + baRest.size() != ScoreboardEntry::size) {
                 break;
             }
 
@@ -448,9 +449,6 @@
         if (it == m_scoreboard.constEnd()) {
             return false;
         }
-        // TODO debug why this seems to fill in wrong info!
-        kDebug(7113);
-        it.value().debugPrint();
         *mcfi = it.value();
         return true;
     }
@@ -512,13 +510,18 @@
         fi.sizeOnDisk = fileInfo.size();
         fi.debugPrint();
         // a CacheFileInfo is-a MiniCacheFileInfo which enables the following assignment...
-        m_scoreboard[CacheIndex(fi.baseName)] = fi;
+        add(fi);
         // finally, return cache dir growth (only relevant if a file was actually created!)
         return ccc == CreateFileNotificationCommand ? fi.sizeOnDisk : 0;
     }
 
-    void fileRemoved(const QString &basename)
+    void add(const CacheFileInfo &fi)
     {
+        m_scoreboard[CacheIndex(fi.baseName)] = fi;
+    }
+
+    void remove(const QString &basename)
+    {
         m_scoreboard.remove(CacheIndex(basename));
     }
 
@@ -655,6 +658,9 @@
                 }
                 if (!gotInfo) {
                     gotInfo = readCacheFile(baseName, fi, CleanCache);
+                    if (gotInfo && scoreboard) {
+                        scoreboard->add(*fi);
+                    }
                 }
                 if (gotInfo) {
                     m_fiList.append(fi);
@@ -691,7 +697,7 @@
             if (QFile::remove(filename)) {
                 m_totalSizeOnDisk -= fi->sizeOnDisk;
                 if (scoreboard) {
-                    scoreboard->fileRemoved(fi->baseName);
+                    scoreboard->remove(fi->baseName);
                 }
             }
             delete fi;
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic