Skip to content

Commit fe86e23

Browse files
committed
Add exception handles
1 parent 6622815 commit fe86e23

File tree

1 file changed

+27
-7
lines changed
  • Plugins/Flow.Launcher.Plugin.Program

1 file changed

+27
-7
lines changed

Plugins/Flow.Launcher.Plugin.Program/Main.cs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,26 +193,46 @@ await Stopwatch.NormalAsync("|Flow.Launcher.Plugin.Program.Main|Preload programs
193193
{
194194
Helper.ValidateDirectory(Context.CurrentPluginMetadata.PluginCacheDirectoryPath);
195195

196-
static bool MoveFile(string sourcePath, string destinationPath)
196+
static void MoveFile(string sourcePath, string destinationPath)
197197
{
198198
if (!File.Exists(sourcePath))
199199
{
200-
return false;
200+
return;
201201
}
202202

203203
if (File.Exists(destinationPath))
204204
{
205-
File.Delete(sourcePath);
206-
return false;
205+
try
206+
{
207+
File.Delete(sourcePath);
208+
}
209+
catch (Exception)
210+
{
211+
// Ignore, we will handle next time we start the plugin
212+
}
213+
return;
207214
}
208215

209216
var destinationDirectory = Path.GetDirectoryName(destinationPath);
210217
if (!Directory.Exists(destinationDirectory) && (!string.IsNullOrEmpty(destinationDirectory)))
211218
{
212-
Directory.CreateDirectory(destinationDirectory);
219+
try
220+
{
221+
Directory.CreateDirectory(destinationDirectory);
222+
}
223+
catch (Exception)
224+
{
225+
// Ignore, we will handle next time we start the plugin
226+
}
227+
}
228+
try
229+
{
230+
File.Move(sourcePath, destinationPath);
231+
}
232+
catch (Exception)
233+
{
234+
// Ignore, we will handle next time we start the plugin
213235
}
214-
File.Move(sourcePath, destinationPath);
215-
return true;
216236
}
217237

218238
// Move old cache files to the new cache directory

0 commit comments

Comments
 (0)