Example #1
0
 /// <summary>
 /// Get the cached entry for the given tlog set, if the table is out of date it is removed from the cache
 /// </summary>
 /// <param name="tLogRootingMarker">The rooting marker for the set of tlogs</param>
 /// <returns>The cached table entry</returns>
 internal static DependencyTableCacheEntry GetCachedEntry(string tLogRootingMarker)
 {
     if (DependencyTable.ContainsKey(tLogRootingMarker))
     {
         DependencyTableCacheEntry cacheEntry = DependencyTable[tLogRootingMarker];
         if (DependencyTableIsUpToDate(cacheEntry))
         {
             return(cacheEntry);
         }
         else
         {
             // Remove the cached entry from memory
             DependencyTable.Remove(tLogRootingMarker);
         }
     }
     // Either there was no cache entry, or it was out of date and was removed
     return(null);
 }
Example #2
0
        /// <summary>
        /// Determine if a cache entry is up to date
        /// </summary>
        /// <param name="dependencyTable">The cache entry to check</param>
        /// <returns>true if up to date</returns>
        private static bool DependencyTableIsUpToDate(DependencyTableCacheEntry dependencyTable)
        {
            DateTime tableTime = dependencyTable.TableTime;

            foreach (ITaskItem tlogFile in dependencyTable.TlogFiles)
            {
                string tlogFilename = FileUtilities.NormalizePath(tlogFile.ItemSpec);

                DateTime lastWriteTime = NativeMethodsShared.GetLastWriteFileUtcTime(tlogFilename);
                if (lastWriteTime > tableTime)
                {
                    // one of the tlog files is newer than the table, so return false
                    return(false);
                }
            }

            return(true);
        }