@@ -20,6 +20,7 @@ namespace avaness.PluginLoader.Data
2020 public class LocalFolderPlugin : PluginData
2121 {
2222 const string XmlDataType = "Xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
23+ const int GitTimeout = 10000 ;
2324
2425 public override string Source => MyTexts . GetString ( MyCommonTexts . Local ) ;
2526 private string [ ] sourceDirectories ;
@@ -104,7 +105,11 @@ private IEnumerable<string> GetProjectFiles(string folder)
104105 // Read the output stream first and then wait.
105106 string gitOutput = p . StandardOutput . ReadToEnd ( ) ;
106107 gitError = p . StandardError . ReadToEnd ( ) ;
107- p . WaitForExit ( ) ;
108+ if ( ! p . WaitForExit ( GitTimeout ) )
109+ {
110+ p . Kill ( ) ;
111+ throw new TimeoutException ( "Git operation timed out." ) ;
112+ }
108113
109114 if ( p . ExitCode == 0 )
110115 {
@@ -113,25 +118,25 @@ private IEnumerable<string> GetProjectFiles(string folder)
113118 }
114119 else
115120 {
116- StringBuilder sb = new StringBuilder ( "An error occurred while checking git for project files. " + p . HasExited ) ;
121+ StringBuilder sb = new StringBuilder ( "An error occurred while checking git for project files." ) . AppendLine ( ) ;
117122 if ( ! string . IsNullOrWhiteSpace ( gitError ) )
118123 {
119- sb . AppendLine ( " Git output: " ) ;
124+ sb . AppendLine ( "Git output: " ) ;
120125 sb . Append ( gitError ) . AppendLine ( ) ;
121126 }
122127 LogFile . WriteLine ( sb . ToString ( ) ) ;
123128 }
124129 }
125130 catch ( Exception e )
126131 {
127- StringBuilder sb = new StringBuilder ( "An error occurred while checking git for project files." ) ;
132+ StringBuilder sb = new StringBuilder ( "An error occurred while checking git for project files." ) . AppendLine ( ) ;
128133 if ( ! string . IsNullOrWhiteSpace ( gitError ) )
129134 {
130135 sb . AppendLine ( " Git output: " ) ;
131136 sb . Append ( gitError ) . AppendLine ( ) ;
132137 }
133138 sb . AppendLine ( "Exception: " ) ;
134- sb . Append ( e ) ;
139+ sb . Append ( e ) . AppendLine ( ) ;
135140 LogFile . WriteLine ( sb . ToString ( ) ) ;
136141 }
137142
0 commit comments