/// <summary> /// Returns a value indicating whether the original file is new or has been updated. /// </summary> /// <returns> /// True if the the original file is new or has been updated; otherwise, false. /// </returns> internal async Task <bool> IsNewOrUpdatedFileAsync() { string path = this.CachedPath; bool isUpdated = false; CachedImage cachedImage; if (this.isRemote) { cachedImage = await CacheIndexer.GetValueAsync(path); if (cachedImage != null) { // Can't check the last write time so check to see if the cached image is set to expire // or if the max age is different. if (this.IsExpired(cachedImage.CreationTimeUtc)) { CacheIndexer.Remove(path); isUpdated = true; } } else { // Nothing in the cache so we should return true. isUpdated = true; } } else { // Test now for locally requested files. cachedImage = await CacheIndexer.GetValueAsync(path); if (cachedImage != null) { FileInfo imageFileInfo = new FileInfo(this.requestPath); if (imageFileInfo.Exists) { // Pull the latest info. imageFileInfo.Refresh(); // Check to see if the last write time is different of whether the // cached image is set to expire or if the max age is different. if (!this.RoughDateTimeCompare(imageFileInfo.LastWriteTimeUtc, cachedImage.LastWriteTimeUtc) || this.IsExpired(cachedImage.CreationTimeUtc)) { CacheIndexer.Remove(path); isUpdated = true; } } } else { // Nothing in the cache so we should return true. isUpdated = true; } } return(isUpdated); }
/// <summary> /// Gets the <see cref="T:System.DateTime"/> set to the last write time of the file. /// </summary> /// <returns> /// The last write time of the file. /// </returns> internal async Task <DateTime> GetLastWriteTimeAsync() { DateTime dateTime = DateTime.UtcNow; CachedImage cachedImage = await CacheIndexer.GetValueAsync(this.CachedPath); if (cachedImage != null) { dateTime = cachedImage.LastWriteTimeUtc; } return(dateTime); }