@@ -89,13 +89,28 @@ private void InitializeSettings()
8989 else /* Defaults for FlashDevelop */
9090 {
9191 String local = Path . Combine ( PathHelper . GetExeDirectory ( ) , @"..\..\.local" ) ;
92+ local = Path . GetFullPath ( local ) ; /* Fix weird path */
9293 if ( ! File . Exists ( local ) )
9394 {
9495 String userAppDir = Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ;
95- String appManDataDir = Path . Combine ( userAppDir , @"FlashDevelop\Data\AppMan" ) ;
96+ String fdUserPath = Path . Combine ( userAppDir , "FlashDevelop" ) ;
97+ String appManDataDir = Path . Combine ( fdUserPath , @"Data\AppMan" ) ;
9698 PathHelper . ARCHIVE_DIR = Path . Combine ( appManDataDir , "Archive" ) ;
9799 PathHelper . LOG_DIR = appManDataDir ;
100+ this . notifyPaths = new String [ 1 ] { fdUserPath } ;
98101 }
102+ else
103+ {
104+ String fdPath = Path . Combine ( PathHelper . GetExeDirectory ( ) , @"..\..\" ) ;
105+ fdPath = Path . GetFullPath ( fdPath ) ; /* Fix weird path */
106+ PathHelper . ARCHIVE_DIR = Path . Combine ( fdPath , @"Data\AppMan\Archive" ) ;
107+ PathHelper . LOG_DIR = Path . Combine ( fdPath , @"Data\AppMan" ) ;
108+ this . notifyPaths = new String [ 1 ] { fdPath } ;
109+ }
110+ }
111+ if ( ! Directory . Exists ( PathHelper . LOG_DIR ) )
112+ {
113+ Directory . CreateDirectory ( PathHelper . LOG_DIR ) ;
99114 }
100115 if ( ! Directory . Exists ( PathHelper . ARCHIVE_DIR ) )
101116 {
@@ -165,7 +180,7 @@ private void MainFormClosed(Object sender, FormClosedEventArgs e)
165180 {
166181 try
167182 {
168- if ( ! this . shouldNotify ) return ;
183+ if ( ! this . shouldNotify && this . notifyPaths == null ) return ;
169184 foreach ( String nPath in this . notifyPaths )
170185 {
171186 try
@@ -441,14 +456,15 @@ private void AddToGroup(ListViewItem item)
441456 /// <summary>
442457 /// Creates a temporary file with the given extension.
443458 /// </summary>
444- private String GetTempFileName ( String file )
459+ private String GetTempFileName ( String file , Boolean unique )
445460 {
446461 try
447462 {
448463 Int32 counter = 0 ;
449464 String tempDir = Path . GetTempPath ( ) ;
450465 String fileName = Path . GetFileName ( file ) ;
451466 String tempFile = Path . Combine ( tempDir , "appman_" + fileName ) ;
467+ if ( ! unique ) return tempFile ;
452468 while ( File . Exists ( tempFile ) )
453469 {
454470 counter ++ ;
@@ -596,7 +612,15 @@ private void DownloadNextFromQueue()
596612 this . fileQueue . Enqueue ( file ) ;
597613 }
598614 this . curFile = this . fileQueue . Dequeue ( ) ;
599- this . tempFile = this . GetTempFileName ( this . curFile ) ;
615+ this . tempFile = this . GetTempFileName ( this . curFile , false ) ;
616+ if ( File . Exists ( this . tempFile ) ) // Use already downloaded temp...
617+ {
618+ String idPath = Path . Combine ( PathHelper . ARCHIVE_DIR , this . curEntry . Id ) ;
619+ String vnPath = Path . Combine ( idPath , this . curEntry . Version . ToLower ( ) ) ;
620+ this . ExtractFile ( this . tempFile , vnPath ) ;
621+ return ;
622+ }
623+ this . tempFile = this . GetTempFileName ( this . curFile , true ) ;
600624 this . webClient . DownloadFileAsync ( new Uri ( this . curFile ) , this . tempFile ) ;
601625 this . statusLabel . Text = "Downloading: " + this . curFile ;
602626 }
@@ -686,14 +710,6 @@ private void WorkerDoWork(Object sender, DoWorkEventArgs e)
686710 DialogHelper . ShowError ( "Error while extracting file: " + this . curFile + ".\n Trying to continue with the next item." ) ;
687711 this . DownloadNextFromQueue ( ) ;
688712 }
689- finally /* Try to delete temp file if not executable */
690- {
691- if ( ! this . IsExecutable ( this . curEntry ) )
692- {
693- try { File . Delete ( this . tempFile ) ; }
694- catch { /* NO ERRORS*/ }
695- }
696- }
697713 }
698714
699715 /// <summary>
@@ -706,7 +722,16 @@ private void WorkerDoCompleted(Object sender, RunWorkerCompletedEventArgs e)
706722 if ( this . fileQueue . Count > 0 )
707723 {
708724 this . curFile = this . fileQueue . Dequeue ( ) ;
709- this . tempFile = this . GetTempFileName ( this . curFile ) ;
725+ this . tempFile = this . GetTempFileName ( this . curFile , false ) ;
726+ if ( File . Exists ( this . tempFile ) ) // Use already downloaded temp...
727+ {
728+ String idPath = Path . Combine ( PathHelper . ARCHIVE_DIR , this . curEntry . Id ) ;
729+ String vnPath = Path . Combine ( idPath , this . curEntry . Version . ToLower ( ) ) ;
730+ this . ExtractFile ( this . tempFile , vnPath ) ;
731+ this . bgWorker . Dispose ( ) ;
732+ return ;
733+ }
734+ this . tempFile = this . GetTempFileName ( this . curFile , true ) ;
710735 this . webClient . DownloadFileAsync ( new Uri ( this . curFile ) , this . tempFile ) ;
711736 this . statusLabel . Text = "Downloading: " + this . curFile ;
712737 }
0 commit comments