diff --git a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileBrowserExpandedNotification.cs b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileBrowserExpandedNotification.cs
index b59cae53..e783919c 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileBrowserExpandedNotification.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileBrowserExpandedNotification.cs
@@ -17,9 +17,14 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser.Contracts
public string OwnerUri;
///
- /// Expanded node
+ /// Expand path
///
- public FileTreeNode ExpandedNode;
+ public string ExpandPath;
+
+ ///
+ /// Children nodes
+ ///
+ public FileTreeNode[] Children;
///
/// Result of the operation
diff --git a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileTreeNode.cs b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileTreeNode.cs
index 1ea2c5be..3f9b1d3b 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileTreeNode.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/Contracts/FileTreeNode.cs
@@ -23,7 +23,7 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser.Contracts
///
/// List of children nodes
///
- public List Children { get; private set; }
+ public List Children { get; set; }
// Indicates if the node is expanded, applicable to a folder.
public bool IsExpanded { get; set; }
diff --git a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserOperation.cs b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserOperation.cs
index 1e1dc3c7..276bd2e9 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserOperation.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserOperation.cs
@@ -52,7 +52,7 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
#endregion
- #region public properties and methods
+ #region public properties
public FileTree FileTree
{
@@ -70,6 +70,8 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
}
}
+ #endregion
+
public void PopulateFileTree()
{
this.PathSeparator = GetPathSeparator(this.Enumerator, this.sqlConnection);
@@ -107,7 +109,7 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
currentNode.IsExpanded = true;
if (!currentNode.IsFile)
{
- PopulateFileNode(currentNode);
+ currentNode.Children = this.GetChildren(currentNode.FullPath);
}
currentChildren = currentNode.Children;
lastNode = currentNode;
@@ -129,38 +131,10 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
}
}
- #endregion
-
- private void PopulateDrives()
+ public List GetChildren(string filepath)
{
- bool first = true;
- foreach (var fileInfo in EnumerateDrives(Enumerator, sqlConnection))
- {
- // Windows drive letter paths have a '\' at the end. Linux drive paths won't have a '\'.
- var node = new FileTreeNode
- {
- Name = Convert.ToString(fileInfo.path, CultureInfo.InvariantCulture).TrimEnd('\\'),
- FullPath = fileInfo.path
- };
-
- this.fileTree.RootNode.AddChildNode(node);
-
- if (first)
- {
- this.fileTree.SelectedNode = node;
- first = false;
- }
-
- PopulateFileNode(node);
- }
- }
-
- private void PopulateFileNode(FileTreeNode parentNode)
- {
- string parentPath = parentNode.FullPath;
- parentNode.Children.Clear();
-
- foreach (var file in EnumerateFilesInFolder(Enumerator, sqlConnection, parentPath))
+ List children = new List();
+ foreach (var file in EnumerateFilesInFolder(Enumerator, sqlConnection, filepath))
{
bool isFile = !string.IsNullOrEmpty(file.fileName);
FileTreeNode treeNode = new FileTreeNode();
@@ -180,9 +154,35 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
// add the node to the tree
if (!isFile || (this.FilterFile(treeNode.Name, this.fileFilters)))
{
- parentNode.AddChildNode(treeNode);
+ children.Add(treeNode);
}
}
+
+ return children;
+ }
+
+ public void PopulateDrives()
+ {
+ bool first = true;
+ foreach (var fileInfo in EnumerateDrives(Enumerator, sqlConnection))
+ {
+ // Windows drive letter paths have a '\' at the end. Linux drive paths won't have a '\'.
+ var node = new FileTreeNode
+ {
+ Name = Convert.ToString(fileInfo.path, CultureInfo.InvariantCulture).TrimEnd('\\'),
+ FullPath = fileInfo.path
+ };
+
+ this.fileTree.RootNode.AddChildNode(node);
+
+ if (first)
+ {
+ this.fileTree.SelectedNode = node;
+ first = false;
+ }
+
+ node.Children = this.GetChildren(node.FullPath);
+ }
}
///
diff --git a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserService.cs b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserService.cs
index e9107dcb..ea83ea7e 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserService.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/FileBrowser/FileBrowserService.cs
@@ -230,9 +230,9 @@ namespace Microsoft.SqlTools.ServiceLayer.FileBrowser
if (this.ownerToFileBrowserMap.ContainsKey(fileBrowserParams.OwnerUri))
{
FileBrowserOperation browser = this.ownerToFileBrowserMap[fileBrowserParams.OwnerUri];
- browser.ExpandSelectedNode(fileBrowserParams.ExpandPath);
+ result.Children = browser.GetChildren(fileBrowserParams.ExpandPath).ToArray();
+ result.ExpandPath = fileBrowserParams.ExpandPath;
result.OwnerUri = fileBrowserParams.OwnerUri;
- result.ExpandedNode = browser.FileTree.SelectedNode;
result.Succeeded = true;
}
else
diff --git a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs
index a9a73e26..7869f338 100644
--- a/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs
+++ b/test/Microsoft.SqlTools.ServiceLayer.IntegrationTests/DisasterRecovery/BackupServiceTests.cs
@@ -288,9 +288,8 @@ CREATE CERTIFICATE {1} WITH SUBJECT = 'Backup Encryption Certificate'; ";
// Verify result
serviceHostMock.Verify(x => x.SendEvent(FileBrowserExpandedNotification.Type,
It.Is(p => p.Succeeded == true
- && p.ExpandedNode != null
- && p.ExpandedNode.Children != null
- && p.ExpandedNode.Children.Count > 0)),
+ && p.Children != null
+ && p.Children.Length > 0)),
Times.Once());
var validateParams = new FileBrowserValidateParams