Skip to content

Commit

Permalink
Fix: Fixed issue that sometimes prevented drives from being displayed (
Browse files Browse the repository at this point in the history
  • Loading branch information
hishitetsu authored Jul 20, 2023
1 parent cc7f269 commit ffb213a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 8 deletions.
29 changes: 29 additions & 0 deletions NOTICE.md
Original file line number Diff line number Diff line change
Expand Up @@ -733,4 +733,33 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
```

## DiscUtils

**Source**: [https://github.com/DiscUtils/DiscUtils](https://github.com/DiscUtils/DiscUtils)

### License

```
Copyright (c) 2008-2011, Kenneth Bell
Copyright (c) 2014, Quamotion
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
```
19 changes: 11 additions & 8 deletions src/Files.App/Utils/Storage/Helpers/DriveHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,20 @@ public static Data.Items.DriveType GetDriveType(System.IO.DriveInfo drive)

public static string GetExtendedDriveLabel(DriveInfo drive)
{
if (drive.DriveType is not System.IO.DriveType.CDRom || drive.DriveFormat is not "UDF")
return drive.VolumeLabel;
return SafetyExtensions.IgnoreExceptions(() =>
{
var dosDevicePath = Vanara.PInvoke.Kernel32.QueryDosDevice(drive.Name).FirstOrDefault();
if (string.IsNullOrEmpty(dosDevicePath))
if (drive.DriveType is not System.IO.DriveType.CDRom || drive.DriveFormat is not "UDF")
return drive.VolumeLabel;
using var driveStream = new FileStream(dosDevicePath.Replace(@"\Device\", @"\\.\"), FileMode.Open, FileAccess.Read);
using var udf = new UdfReader(driveStream);
return udf.VolumeLabel;
}) ?? drive.VolumeLabel;
return SafetyExtensions.IgnoreExceptions(() =>
{
var dosDevicePath = Vanara.PInvoke.Kernel32.QueryDosDevice(drive.Name).FirstOrDefault();
if (string.IsNullOrEmpty(dosDevicePath))
return drive.VolumeLabel;
using var driveStream = new FileStream(dosDevicePath.Replace(@"\Device\", @"\\.\"), FileMode.Open, FileAccess.Read);
using var udf = new UdfReader(driveStream);
return udf.VolumeLabel;
}) ?? drive.VolumeLabel;
}) ?? "";
}

public static async Task<StorageItemThumbnail> GetThumbnailAsync(StorageFolder folder)
Expand Down

0 comments on commit ffb213a

Please sign in to comment.