mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-05-11 02:34:08 +02:00
Delete corrupted downloads after an error
This commit is contained in:
parent
11d978dad1
commit
5e3bd31862
@ -26,13 +26,10 @@ public static WebClient NewClient(string userAgent){
|
||||
public static AsyncCompletedEventHandler FileDownloadCallback(string file, Action? onSuccess, Action<Exception>? onFailure){
|
||||
return (sender, args) => {
|
||||
if (args.Cancelled){
|
||||
try{
|
||||
File.Delete(file);
|
||||
}catch{
|
||||
// didn't want it deleted anyways
|
||||
}
|
||||
TryDeleteFile(file);
|
||||
}
|
||||
else if (args.Error != null){
|
||||
TryDeleteFile(file);
|
||||
onFailure?.Invoke(args.Error);
|
||||
}
|
||||
else{
|
||||
@ -40,5 +37,13 @@ public static AsyncCompletedEventHandler FileDownloadCallback(string file, Actio
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static void TryDeleteFile(string file){
|
||||
try{
|
||||
File.Delete(file);
|
||||
}catch{
|
||||
// didn't want it deleted anyways
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user