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 33using System . Globalization ;
44using System . IO ;
55using System . Runtime . CompilerServices ;
6+ using System . Threading ;
67using System . Threading . Tasks ;
78using System . Windows ;
89using System . Windows . Controls ;
@@ -149,8 +150,15 @@ public static string GetFolderSize(string folderPath)
149150 {
150151 var directoryInfo = new DirectoryInfo ( folderPath ) ;
151152 long size = 0 ;
153+ var cancellationTokenSource = new CancellationTokenSource ( TimeSpan . FromSeconds ( 3 ) ) ;
152154 foreach ( var file in directoryInfo . GetFiles ( "*" , SearchOption . AllDirectories ) )
153155 {
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+ }
154162 size += file . Length ;
155163 }
156164 return ResultManager . ToReadableSize ( size , 2 ) ;
You can’t perform that action at this time.
0 commit comments