99using System . Xml . Linq ;
1010using EnvDTE ;
1111using Ionic . Zip ;
12- using Npgsql ;
1312using Oracle . ManagedDataAccess . Client ;
13+ using Revenj . DatabasePersistence . Postgres . Npgsql ;
1414
1515namespace DSLPlatform
1616{
@@ -165,6 +165,9 @@ public static Either<bool> DownloadZip(string fromWhere, string zipName, string
165165 foreach ( var ze in zf . Entries )
166166 {
167167 zipFiles . Add ( ze . FileName ) ;
168+ var filename = Path . Combine ( path , ze . FileName ) ;
169+ TryDelete ( filename + ".tmp" ) ;
170+ TryDelete ( filename + ".PendingOverwrite" ) ;
168171 ze . Extract ( path , ExtractExistingFileAction . OverwriteSilently ) ;
169172 }
170173 }
@@ -174,6 +177,17 @@ public static Either<bool> DownloadZip(string fromWhere, string zipName, string
174177 } ) ;
175178 }
176179
180+ private static void TryDelete ( string file )
181+ {
182+ var fi = new FileInfo ( file ) ;
183+ if ( ! fi . Exists ) return ;
184+ try
185+ {
186+ fi . Delete ( ) ;
187+ }
188+ catch { }
189+ }
190+
177191 private static Dictionary < string , string > GatherCurrentDsl ( DTE dte )
178192 {
179193 var dsls = new Dictionary < string , string > ( ) ;
@@ -554,15 +568,15 @@ private static DbInfo ReadInfoFromOracle(DatabaseInfo dbInfo)
554568
555569 private static DbInfo ReadInfoFromPostgres ( DatabaseInfo dbInfo )
556570 {
557- var postgresVersion = new Version ( 9 , 3 ) ;
571+ var postgresVersion = new Version ( 11 , 0 ) ;
558572 try
559573 {
560574 using ( var conn = new NpgsqlConnection ( dbInfo . ConnectionString ) )
561575 {
562576 var com = conn . CreateCommand ( ) ;
563577 conn . Open ( ) ;
564578 if ( ! Version . TryParse ( conn . ServerVersion , out postgresVersion ) )
565- postgresVersion = new Version ( 9 , 3 ) ;
579+ postgresVersion = new Version ( 11 , 0 ) ;
566580 IDataReader dr ;
567581 try
568582 {
@@ -607,10 +621,10 @@ private static void ApplyPostgresMigration(Stream stream, bool force, DatabaseIn
607621 {
608622 if ( ! force )
609623 CheckForce ( stream ) ;
610- using ( var conn = new Npgsql . NpgsqlConnection ( dbInfo . ConnectionString ) )
624+ using ( var conn = new NpgsqlConnection ( dbInfo . ConnectionString ) )
611625 {
612626 conn . Open ( ) ;
613- var com = new Npgsql . NpgsqlCommand ( stream ) ;
627+ var com = new NpgsqlCommand ( stream ) ;
614628 com . Connection = conn ;
615629 com . ExecuteNonQuery ( ) ;
616630 conn . Close ( ) ;
0 commit comments