diff --git a/CHANGELOG.md b/CHANGELOG.md index 173e0ff..7a60fbd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [Unreleased] + +## 17.4.43 (2020-01-14) + +### Azure Cloud File System Provider + +#### Bug Fixes + +- `#149499` - The issue with date modified has been fixed. + ## 17.3.26 (2019-11-05) ### Azure Cloud File System Provider diff --git a/Models/AzureFileProvider.cs b/Models/AzureFileProvider.cs index 6fccc1f..4f6097c 100644 --- a/Models/AzureFileProvider.cs +++ b/Models/AzureFileProvider.cs @@ -31,18 +31,19 @@ namespace Syncfusion.EJ2.FileManager.AzureFileProvider public class AzureFileProvider : AzureFileProviderBase { List Items = new List(); - private CloudBlobContainer container; - private CloudBlobDirectory item; - private string PathValue; - private string BlobPath; - private string FilesPath; - private string DownloadLocation; - private long size; - private string rootPath; - private List existFiles = new List(); - private List missingFiles = new List(); - private bool isFolderAvailable = false; - private List copiedFiles = new List(); + CloudBlobContainer container; + CloudBlobDirectory item; + string PathValue; + string BlobPath; + string FilesPath; + long size; + string rootPath; + List existFiles = new List(); + List missingFiles = new List(); + bool isFolderAvailable = false; + List copiedFiles = new List(); + DateTime lastUpdated = DateTime.MinValue; + DateTime prevUpdated = DateTime.MinValue; // Registering the azure storage public void RegisterAzure(string accountName, string accountKey, string blobName) @@ -131,6 +132,8 @@ protected async Task GetFilesAsync(string path, string filt entry.Size = 0; entry.HasChild = await HasChildDirectory(directory.Prefix); entry.FilterPath = selectedItems.Length > 0 ? path.Replace(this.rootPath, "") : "/"; + entry.DateModified = await DirectoryLastModified(directory.Prefix); + lastUpdated = prevUpdated = DateTime.MinValue; details.Add(entry); } } @@ -143,6 +146,28 @@ protected async Task GetFilesAsync(string path, string filt readResponse.Files = details; return readResponse; } + // Returns the last modified date for directories + protected async Task DirectoryLastModified(string path) + { + BlobResultSegment items = await AsyncReadCall(path, "Read"); + //Checks the corresponding folder's last modified date of recent updated file from any of its sub folders. + if (items.Results.Where(x => x.GetType() == typeof(CloudBlobDirectory)).Select(x => x).ToList().Count > 0) + { + List folderItems = items.Results.Where(x => x.GetType() == typeof(CloudBlobDirectory)).Select(x => x).ToList(); + foreach (IListBlobItem item in folderItems) + { + DateTime checkFolderModified = DirectoryLastModified(((CloudBlobDirectory)item).Prefix).Result; + lastUpdated = prevUpdated = (prevUpdated < checkFolderModified) ? checkFolderModified : prevUpdated; + } + } + //Checks the corresponding folder's last modified date of recent updated file + if (items.Results.Where(x => x.GetType() == typeof(CloudBlockBlob)).Select(x => x).ToList().Count > 0) + { + DateTime checkFileModified = ((CloudBlockBlob)items.Results.Where(x => x.GetType() == typeof(CloudBlockBlob)).Select(x => x).ToList().OrderByDescending(m => ((CloudBlockBlob)m).Properties.LastModified).ToList().First()).Properties.LastModified.Value.LocalDateTime; + lastUpdated = prevUpdated = prevUpdated < checkFileModified ? checkFileModified : prevUpdated; + } + return lastUpdated; + } // Converts the byte size value to appropriate value protected string byteConversion(long fileSize) {