File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Plugins/Flow.Launcher.Plugin.Explorer/Views Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 3
3
using System . Globalization ;
4
4
using System . IO ;
5
5
using System . Runtime . CompilerServices ;
6
+ using System . Threading ;
6
7
using System . Threading . Tasks ;
7
8
using System . Windows ;
8
9
using System . Windows . Controls ;
@@ -149,8 +150,15 @@ public static string GetFolderSize(string folderPath)
149
150
{
150
151
var directoryInfo = new DirectoryInfo ( folderPath ) ;
151
152
long size = 0 ;
153
+ var cancellationTokenSource = new CancellationTokenSource ( TimeSpan . FromSeconds ( 3 ) ) ;
152
154
foreach ( var file in directoryInfo . GetFiles ( "*" , SearchOption . AllDirectories ) )
153
155
{
156
+ if ( cancellationTokenSource . Token . IsCancellationRequested )
157
+ {
158
+ // Timeout occurred, return unknown size
159
+ cancellationTokenSource . Dispose ( ) ;
160
+ return Main . Context . API . GetTranslation ( "plugin_explorer_plugin_tooltip_more_info_unknown" ) ;
161
+ }
154
162
size += file . Length ;
155
163
}
156
164
return ResultManager . ToReadableSize ( size , 2 ) ;
You can’t perform that action at this time.
0 commit comments