@@ -25,13 +25,25 @@ public static async Task DownloadAsync<TDataSet>(this IModelLoader<TDataSet> mod
2525 if ( ! Path . IsPathRooted ( dirSaveTo ) )
2626 dirSaveTo = Path . Combine ( AppContext . BaseDirectory , dirSaveTo ) ;
2727
28- if ( ! Directory . Exists ( dirSaveTo ) )
29- Directory . CreateDirectory ( dirSaveTo ) ;
30-
31- using ( var wc = new WebClient ( ) )
28+ var fileSaveTo = Path . Combine ( dirSaveTo , fileName ) ;
29+
30+ if ( File . Exists ( fileSaveTo ) )
3231 {
33- await wc . DownloadFileTaskAsync ( url , Path . Combine ( dirSaveTo , fileName ) ) ;
32+ //TODO:maybe you can check file's hashcode and "donglowad.info" to complete file ...
33+ Console . WriteLine ( $ "{ fileSaveTo } already exists.") ;
3434 }
35+ else
36+ {
37+ if ( ! Directory . Exists ( dirSaveTo ) )
38+ Directory . CreateDirectory ( dirSaveTo ) ;
39+
40+ using ( var wc = new WebClient ( ) )
41+ {
42+ await wc . DownloadFileTaskAsync ( url , fileSaveTo ) ;
43+ }
44+
45+ }
46+
3547 }
3648
3749 public static async Task UnzipAsync < TDataSet > ( this IModelLoader < TDataSet > modelLoader , string zipFile , string saveTo )
@@ -42,7 +54,7 @@ public static async Task UnzipAsync<TDataSet>(this IModelLoader<TDataSet> modelL
4254
4355 if ( ! Directory . Exists ( saveTo ) )
4456 Directory . CreateDirectory ( saveTo ) ;
45-
57+
4658 if ( ! Path . IsPathRooted ( zipFile ) )
4759 zipFile = Path . Combine ( AppContext . BaseDirectory , zipFile ) ;
4860
@@ -78,15 +90,15 @@ public static async Task ShowProgressInConsole(this Task task, bool enable)
7890
7991 var cts = new CancellationTokenSource ( ) ;
8092 var showProgressTask = ShowProgressInConsole ( cts ) ;
81-
93+
8294 try
8395 {
8496 await task ;
8597 }
8698 finally
8799 {
88100 cts . Cancel ( ) ;
89- }
101+ }
90102 }
91103
92104 private static async Task ShowProgressInConsole ( CancellationTokenSource cts )
0 commit comments