Skip to content

Commit 188f6ab

Browse files
authored
Minor fixes to FTP (#6646)
1 parent de1e803 commit 188f6ab

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Files/ViewModels/ItemViewModel.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1377,12 +1377,26 @@ await Task.Run(async () =>
13771377
client.Host = FtpHelpers.GetFtpHost(path);
13781378
client.Port = FtpHelpers.GetFtpPort(path);
13791379
client.Credentials = FtpManager.Credentials.Get(client.Host, FtpManager.Anonymous);
1380+
1381+
static async Task<FtpProfile> WrappedAutoConnectFtpAsync(FtpClient client)
1382+
{
1383+
try
1384+
{
1385+
return await client.AutoConnectAsync();
1386+
}
1387+
catch (FtpAuthenticationException)
1388+
{
1389+
return null;
1390+
}
1391+
1392+
throw new InvalidOperationException();
1393+
}
13801394

13811395
await Task.Run(async () =>
13821396
{
13831397
try
13841398
{
1385-
if (!client.IsConnected && await client.AutoConnectAsync() is null)
1399+
if (!client.IsConnected && await WrappedAutoConnectFtpAsync(client) is null)
13861400
{
13871401
await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () =>
13881402
{
@@ -1403,7 +1417,7 @@ await CoreApplication.MainView.DispatcherQueue.EnqueueAsync(async () =>
14031417
}
14041418
});
14051419
}
1406-
if (!client.IsConnected && await client.AutoConnectAsync() is null)
1420+
if (!client.IsConnected && await WrappedAutoConnectFtpAsync(client) is null)
14071421
{
14081422
throw new InvalidOperationException();
14091423
}

0 commit comments

Comments
 (0)