Skip to content

Commit ffb213a

Browse files
authored
Fix: Fixed issue that sometimes prevented drives from being displayed (#12986)
1 parent cc7f269 commit ffb213a

File tree

2 files changed

+40
-8
lines changed

2 files changed

+40
-8
lines changed

NOTICE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,4 +733,33 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
733733
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
734734
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
735735
THE SOFTWARE.
736+
```
737+
738+
## DiscUtils
739+
740+
**Source**: [https://github.com/DiscUtils/DiscUtils](https://github.com/DiscUtils/DiscUtils)
741+
742+
### License
743+
744+
```
745+
Copyright (c) 2008-2011, Kenneth Bell
746+
Copyright (c) 2014, Quamotion
747+
748+
Permission is hereby granted, free of charge, to any person obtaining a
749+
copy of this software and associated documentation files (the "Software"),
750+
to deal in the Software without restriction, including without limitation
751+
the rights to use, copy, modify, merge, publish, distribute, sublicense,
752+
and/or sell copies of the Software, and to permit persons to whom the
753+
Software is furnished to do so, subject to the following conditions:
754+
755+
The above copyright notice and this permission notice shall be included in
756+
all copies or substantial portions of the Software.
757+
758+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
759+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
760+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
761+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
762+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
763+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
764+
DEALINGS IN THE SOFTWARE.
736765
```

src/Files.App/Utils/Storage/Helpers/DriveHelpers.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,20 @@ public static Data.Items.DriveType GetDriveType(System.IO.DriveInfo drive)
130130

131131
public static string GetExtendedDriveLabel(DriveInfo drive)
132132
{
133-
if (drive.DriveType is not System.IO.DriveType.CDRom || drive.DriveFormat is not "UDF")
134-
return drive.VolumeLabel;
135133
return SafetyExtensions.IgnoreExceptions(() =>
136134
{
137-
var dosDevicePath = Vanara.PInvoke.Kernel32.QueryDosDevice(drive.Name).FirstOrDefault();
138-
if (string.IsNullOrEmpty(dosDevicePath))
135+
if (drive.DriveType is not System.IO.DriveType.CDRom || drive.DriveFormat is not "UDF")
139136
return drive.VolumeLabel;
140-
using var driveStream = new FileStream(dosDevicePath.Replace(@"\Device\", @"\\.\"), FileMode.Open, FileAccess.Read);
141-
using var udf = new UdfReader(driveStream);
142-
return udf.VolumeLabel;
143-
}) ?? drive.VolumeLabel;
137+
return SafetyExtensions.IgnoreExceptions(() =>
138+
{
139+
var dosDevicePath = Vanara.PInvoke.Kernel32.QueryDosDevice(drive.Name).FirstOrDefault();
140+
if (string.IsNullOrEmpty(dosDevicePath))
141+
return drive.VolumeLabel;
142+
using var driveStream = new FileStream(dosDevicePath.Replace(@"\Device\", @"\\.\"), FileMode.Open, FileAccess.Read);
143+
using var udf = new UdfReader(driveStream);
144+
return udf.VolumeLabel;
145+
}) ?? drive.VolumeLabel;
146+
}) ?? "";
144147
}
145148

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

0 commit comments

Comments
 (0)