예제 #1
0
        internal bool MeetsOverMaxCriteria(CachedFileInfo i)
        {
            DateTime now = DateTime.UtcNow;

            //Only require the 'used' date to comply if it 1) doesn't match created date and 2) is above 0
            return((now.Subtract(i.AccessedUtc) > ProhibitRemovalIfUsedWithin || ProhibitRemovalIfUsedWithin <= new TimeSpan(0) || i.AccessedUtc == i.UpdatedUtc) &&
                   (now.Subtract(i.UpdatedUtc) > ProhibitRemovalIfCreatedWithin || ProhibitRemovalIfCreatedWithin <= new TimeSpan(0)));
        }
 /// <summary>
 /// Uses old.AccessedUtc if it is newer than FileInfo.LastAccessTimeUtc
 /// </summary>
 /// <param name="f"></param>
 /// <param name="old"></param>
 public CachedFileInfo(FileInfo f, CachedFileInfo old)
 {
     ModifiedUtc = f.LastWriteTimeUtc;
     AccessedUtc = f.LastAccessTimeUtc;
     if (old != null && AccessedUtc < old.AccessedUtc)
     {
         AccessedUtc = old.AccessedUtc;                                               //Use the larger value
     }
     UpdatedUtc = f.CreationTimeUtc;
 }
        public void FlushAccessedDate(CleanupWorkItem item)
        {
            CachedFileInfo c = cache.Index.getCachedFileInfo(item.RelativePath);

            if (c == null)
            {
                return;            //File was already deleted, nothing to do.
            }
            try{
                cache.Locks.TryExecute(item.RelativePath.ToUpperInvariant(), 1, delegate()
                {
                    File.SetLastAccessTimeUtc(item.PhysicalPath, c.AccessedUtc);
                });
                //In both of these exception cases, we don't care.
            }catch (FileNotFoundException) {
            }catch (UnauthorizedAccessException) {
            }
        }
예제 #4
0
 internal bool ShouldRemove(string relativePath, CachedFileInfo info, bool isOverMax)
 {
     return(isOverMax ? MeetsOverMaxCriteria(info) : MeetsCleanupCriteria(info));
 }
 public CachedFileInfo(CachedFileInfo f, DateTime accessedDate)
 {
     this.ModifiedUtc = f.ModifiedUtc;
     this.UpdatedUtc  = f.UpdatedUtc;
     this.AccessedUtc = accessedDate;
 }