@@ -83,28 +83,19 @@ public static List<DLLCHARACTERISTICS> GetDllCharacteristics(string Path)
83
83
}
84
84
// This can happen if the file is readable but not writable as MMFile tries to open the file with write privileges.
85
85
// When we fail we can retry by reading the file to a Stream first, which cen be less performant but works with just Read access
86
- // See #684
87
- catch ( UnauthorizedAccessException )
86
+ // See #684 + #696
87
+ catch ( Exception e ) when ( e is UnauthorizedAccessException or IOException )
88
88
{
89
89
try
90
90
{
91
91
using var stream = File . OpenRead ( Path ) ;
92
92
return GetDllCharacteristics ( Path , stream ) ;
93
93
}
94
- catch ( Exception e )
94
+ catch ( Exception ex )
95
95
{
96
- Log . Debug ( e , "Failed to get DLL Characteristics for {0} ({1}:{2})" , Path , e . GetType ( ) , e . Message ) ;
96
+ Log . Debug ( ex , "Failed to get DLL Characteristics for {0} ({1}:{2})" , Path , ex . GetType ( ) , ex . Message ) ;
97
97
}
98
98
}
99
- catch ( Exception e ) when (
100
- e is IndexOutOfRangeException
101
- || e is ArgumentNullException
102
- || e is System . IO . IOException
103
- || e is ArgumentException
104
- || e is NullReferenceException )
105
- {
106
- Log . Debug ( "Failed to get DLL Characteristics for {0} ({1}:{2})" , Path , e . GetType ( ) , e . Message ) ;
107
- }
108
99
catch ( Exception e )
109
100
{
110
101
Log . Debug ( e , "Failed to get DLL Characteristics for {0} ({1}:{2})" , Path , e . GetType ( ) , e . Message ) ;
@@ -185,18 +176,18 @@ private static List<DLLCHARACTERISTICS> CharacteristicsTypeToListOfCharacteristi
185
176
}
186
177
}
187
178
// This can happen if the file is readable but not writable as MMFile tries to open the file with write privileges.
188
- // When we fail we can retry by reading the file to a Stream first, which cen be less performant but works with just Read access
189
- // See #684
190
- catch ( UnauthorizedAccessException )
179
+ // When we fail we can retry by reading the file to a Stream first, which can be less performant but works with just Read access
180
+ // See #684 + #696
181
+ catch ( Exception e ) when ( e is UnauthorizedAccessException or IOException )
191
182
{
192
183
try
193
184
{
194
185
using var stream = File . OpenRead ( Path ) ;
195
186
return GetSignatureStatus ( Path , stream ) ;
196
187
}
197
- catch ( Exception e )
188
+ catch ( Exception ex )
198
189
{
199
- Log . Debug ( e , "Failed to get signature for {0} ({1}:{2})" , Path , e . GetType ( ) , e . Message ) ;
190
+ Log . Debug ( ex , "Failed to get signature for {0} ({1}:{2})" , Path , ex . GetType ( ) , ex . Message ) ;
200
191
}
201
192
}
202
193
catch ( Exception e )
@@ -206,6 +197,11 @@ private static List<DLLCHARACTERISTICS> CharacteristicsTypeToListOfCharacteristi
206
197
return null ;
207
198
}
208
199
200
+ /// <summary>
201
+ /// Try to determine if the file is locally present to avoid triggering a downloading files that are cloud stubs
202
+ /// </summary>
203
+ /// <param name="path">Path to check</param>
204
+ /// <returns>True when the file appears to be local based on its attributes</returns>
209
205
public static bool IsLocal ( string path )
210
206
{
211
207
NativeMethods . WIN32_FILE_ATTRIBUTE_DATA fileData ;
0 commit comments