Skip to content

Commit

Permalink
Fix error when a path is too long upon scanning books.
Browse files Browse the repository at this point in the history
close #57
  • Loading branch information
maforget committed Mar 10, 2024
1 parent 2542eee commit 46ccb76
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions cYo.Common/IO/DriveChecker.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;

Expand All @@ -9,20 +10,27 @@ public class DriveChecker

public bool IsConnected(string path)
{
string text = Path.GetPathRoot(path).ToLower();
if (!cache.TryGetValue(text, out var value))
try
{
try
string text = Path.GetPathRoot(path).ToLower();
if (!cache.TryGetValue(text, out var value))
{
value = Directory.Exists(text);
try
{
value = Directory.Exists(text);
}
catch
{
value = false;
}
cache[text] = value;
}
catch
{
value = false;
}
cache[text] = value;
return value;
}
catch (Exception)
{
return false;
}
return value;
}
}
}

0 comments on commit 46ccb76

Please sign in to comment.