Pārlūkot izejas kodu

Don't update cache timestamp, if reading XML from cache

Matt Clarkson 11 gadi atpakaļ
vecāks
revīzija
d4a1873e0b

+ 5 - 2
Libs/CommandLineModules/Core/ctkCmdLineModuleManager.cpp

@@ -151,10 +151,13 @@ ctkCmdLineModuleManager::registerModule(const QUrl &location)
 
   bool fromCache = false;
   qint64 newTimeStamp = 0;
+  qint64 cacheTimeStamp = 0;
   if (d->ModuleCache)
   {
     newTimeStamp = backend->timeStamp(location);
-    if (d->ModuleCache->timeStamp(location) < newTimeStamp)
+    cacheTimeStamp = d->ModuleCache->timeStamp(location);
+    if (cacheTimeStamp < 0                // i.e. timestamp is invalid
+        || cacheTimeStamp < newTimeStamp) // i.e. timestamp is genuinely out of date
     {
       // newly fetch the XML description
       try
@@ -221,7 +224,7 @@ ctkCmdLineModuleManager::registerModule(const QUrl &location)
     }
     else
     {
-      if (d->ModuleCache && newTimeStamp > 0)
+      if (d->ModuleCache && newTimeStamp > 0 && !fromCache)
       {
         // successfully validated the xml, cache it
         d->ModuleCache->cacheXmlDescription(location, newTimeStamp, xml);