Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change to scope file tree to the known path if root folders dont return correctly #816

Merged
merged 2 commits into from
May 25, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,19 @@ public void ExpandSelectedNode(string expandPath)
{
this.fileTree.SelectedNode = lastNode;
}
throw new FileBrowserException(string.Format(SR.InvalidPathError, this.expandPath));

// If root folders returned from sys.dm_os_enumerate_filesystem don't match the folders present, expandPath might not be found
// Bug: https://github.com/microsoft/azuredatastudio/issues/4767
// Workaround : scope file browser tree to expandPath explicitly
try
{
this.ScopeFileTreeToPath(expandPath);
return;
}
catch
udeeshagautam marked this conversation as resolved.
Show resolved Hide resolved
{
throw new FileBrowserException(string.Format(SR.InvalidPathError, this.expandPath));
}
}
}

Expand Down Expand Up @@ -204,7 +216,7 @@ public void PopulateDrives()
}

public List<FileTreeNode> GetChildren(string filePath)
{
{
List<FileTreeNode> children = new List<FileTreeNode>();
foreach (var file in EnumerateFilesInFolder(Enumerator, connection, filePath))
{
Expand Down Expand Up @@ -248,6 +260,26 @@ internal bool FilterFile(string fileName, string[] masks)
return false;
}

/// <summary>
/// Creates file tree for a scoped path
/// Removes the top level file tree so only use this if you intend to do that
/// </summary>
/// <param name="expandPath">path to consider at top level node for tree</param>
private void ScopeFileTreeToPath(string expandPath)
{
this.fileTree = new FileTree();
FileTreeNode node = new FileTreeNode()
{
Name = expandPath,
FullPath = expandPath,
IsExpanded = true
};

this.fileTree.RootNode.AddChildNode(node);
udeeshagautam marked this conversation as resolved.
Show resolved Hide resolved
node.Children = node.Children = this.GetChildren(node.FullPath);
udeeshagautam marked this conversation as resolved.
Show resolved Hide resolved
this.fileTree.SelectedNode = node;
}

/// <summary>
/// Compares a file name to the user specified mask using a regular expression
/// </summary>
Expand Down