Skip to content

Commit

Permalink
Merge pull request SyncfusionExamples#6 from Bhuvaneswarin/master
Browse files Browse the repository at this point in the history
feature(EJ2-35685): Updated the Date Modified issue fix and changelog in Azure file system provider
  • Loading branch information
gsumankumar authored Jan 22, 2020
2 parents 2b8fa90 + e9d87c2 commit 964f683
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 12 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
49 changes: 37 additions & 12 deletions Models/AzureFileProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@ namespace Syncfusion.EJ2.FileManager.AzureFileProvider
public class AzureFileProvider : AzureFileProviderBase
{
List<FileManagerDirectoryContent> Items = new List<FileManagerDirectoryContent>();
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<string> existFiles = new List<string>();
private List<string> missingFiles = new List<string>();
private bool isFolderAvailable = false;
private List<FileManagerDirectoryContent> copiedFiles = new List<FileManagerDirectoryContent>();
CloudBlobContainer container;
CloudBlobDirectory item;
string PathValue;
string BlobPath;
string FilesPath;
long size;
string rootPath;
List<string> existFiles = new List<string>();
List<string> missingFiles = new List<string>();
bool isFolderAvailable = false;
List<FileManagerDirectoryContent> copiedFiles = new List<FileManagerDirectoryContent>();
DateTime lastUpdated = DateTime.MinValue;
DateTime prevUpdated = DateTime.MinValue;

// Registering the azure storage
public void RegisterAzure(string accountName, string accountKey, string blobName)
Expand Down Expand Up @@ -131,6 +132,8 @@ protected async Task<FileManagerResponse> 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);
}
}
Expand All @@ -143,6 +146,28 @@ protected async Task<FileManagerResponse> GetFilesAsync(string path, string filt
readResponse.Files = details;
return readResponse;
}
// Returns the last modified date for directories
protected async Task<DateTime> 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<IListBlobItem> 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)
{
Expand Down

0 comments on commit 964f683

Please sign in to comment.