Skip to content

Commit 51b68b7

Browse files
Fix: Fixed a crash with ftp connections (#12228)
1 parent d8d10c2 commit 51b68b7

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Files.App/ViewModels/ItemViewModel.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,11 @@ public async Task SetWorkingDirectoryAsync(string? value)
139139
_ = Task.Run(() => jumpListService.AddFolderAsync(value));
140140

141141
WorkingDirectory = value;
142-
GitDirectory = GitHelpers.GetGitRepositoryPath(WorkingDirectory, Path.GetPathRoot(WorkingDirectory));
142+
143+
var pathRoot = FtpHelpers.IsFtpPath(WorkingDirectory)
144+
? WorkingDirectory.Substring(0, FtpHelpers.GetRootIndex(WorkingDirectory))
145+
: Path.GetPathRoot(WorkingDirectory);
146+
GitDirectory = pathRoot is null ? null : GitHelpers.GetGitRepositoryPath(WorkingDirectory, pathRoot);
143147
OnPropertyChanged(nameof(WorkingDirectory));
144148
}
145149

0 commit comments

Comments
 (0)