@@ -40,7 +40,7 @@ public partial class MainWindow : Window
4040
4141 int MajorV = 3 ;
4242 int MinorV = 11 ;
43- int PatchV = 3 ;
43+ int PatchV = 4 ;
4444 Boolean Preview = false ;
4545
4646 String IP = "" ;
@@ -54,13 +54,20 @@ public partial class MainWindow : Window
5454 Boolean Running = false ;
5555 Boolean OneClick = false ;
5656 Boolean OneClickQSU = false ;
57- String exe = AppDomain . CurrentDomain . BaseDirectory ;
57+ String exe = AppDomain . CurrentDomain . BaseDirectory . Substring ( 0 , AppDomain . CurrentDomain . BaseDirectory . Length - 1 ) ;
5858 ArrayList P = new ArrayList ( ) ;
5959 int Lists = 0 ;
60+ int Open = 0 ;
6061 String args = "" ;
6162
6263 public async Task KeyAsync ( String key )
6364 {
65+ int c = 0 ;
66+ while ( File . Exists ( exe + "\\ tmp\\ Song" + c + ".zip" ) ) {
67+ c ++ ;
68+ }
69+ Open = c ;
70+
6471 StartBMBF ( ) ;
6572 QuestIP ( ) ;
6673
@@ -81,7 +88,7 @@ public async Task KeyAsync(String key)
8188 Application . Current . Dispatcher . Invoke ( DispatcherPriority . Background , new Action ( delegate
8289 {
8390 client . DownloadFileCompleted += new AsyncCompletedEventHandler ( finished_download ) ;
84- client . DownloadFileAsync ( keys , exe + "\\ tmp\\ Song.zip" ) ;
91+ client . DownloadFileAsync ( keys , exe + "\\ tmp\\ Song" + Open + " .zip") ;
8592 } ) ) ;
8693 }
8794 catch
@@ -110,8 +117,12 @@ public void upload(String path)
110117 }
111118 try
112119 {
113- Sync ( ) ;
120+ Application . Current . Dispatcher . Invoke ( DispatcherPriority . Background , new Action ( delegate
121+ {
122+ Sync ( ) ;
123+ } ) ) ;
114124 txtbox . AppendText ( "\n \n Song " + keyName + " (" + args + ") was synced to your Quest." ) ;
125+ this . Close ( ) ;
115126 } catch
116127 {
117128 txtbox . AppendText ( "\n \n Couldn't sync with BeatSaber. Needs to be done manually." ) ;
@@ -121,8 +132,7 @@ public void upload(String path)
121132 public void finished_download ( object sender , AsyncCompletedEventArgs e )
122133 {
123134 txtbox . AppendText ( "\n Downloaded BeatMap " + args + "\n " ) ;
124- unzip ( exe + "\\ tmp" , true ) ;
125- upload ( exe + "\\ tmp\\ Song.zip" ) ;
135+ upload ( exe + "\\ tmp\\ Song" + Open + ".zip" ) ;
126136 }
127137
128138 public MainWindow ( )
@@ -175,6 +185,7 @@ public void checks()
175185
176186 StreamReader r = new StreamReader ( @exe + "\\ Info.json" ) ;
177187 String Info = r . ReadToEnd ( ) ;
188+ r . Close ( ) ;
178189 var json = JSON . Parse ( Info ) ;
179190
180191 if ( ! json [ "Version" ] . ToString ( ) . Equals ( "\" " + MajorV . ToString ( ) + MinorV . ToString ( ) + PatchV . ToString ( ) + "\" " ) )
@@ -761,16 +772,19 @@ public void Update()
761772 try
762773 {
763774 //Download Update.txt
764- using ( WebClient client = new WebClient ( ) )
775+ if ( ! File . Exists ( exe + " \\ tmp \\ Update.txt" ) )
765776 {
766- try
777+ using ( WebClient client = new WebClient ( ) )
767778 {
768- client . DownloadFile ( "https://raw.githubusercontent.com/ComputerElite/QSE/master/Update.txt" , exe + "\\ tmp\\ Update.txt" ) ;
769- }
770- catch
771- {
772- txtbox . AppendText ( "\n \n \n An error Occured (Code: UD100). Couldn't check for Updates. Check following" ) ;
773- txtbox . AppendText ( "\n \n - Your PC has internet." ) ;
779+ try
780+ {
781+ client . DownloadFile ( "https://raw.githubusercontent.com/ComputerElite/QSE/master/Update.txt" , exe + "\\ tmp\\ Update.txt" ) ;
782+ }
783+ catch
784+ {
785+ txtbox . AppendText ( "\n \n \n An error Occured (Code: UD100). Couldn't check for Updates. Check following" ) ;
786+ txtbox . AppendText ( "\n \n - Your PC has internet." ) ;
787+ }
774788 }
775789 }
776790 StreamReader VReader = new StreamReader ( exe + "\\ tmp\\ Update.txt" ) ;
@@ -832,11 +846,17 @@ public void Update()
832846 txtbox . AppendText ( "\n \n Looks like you have a preview version. The release version has been released. Please Update now. " ) ;
833847 UpdateB . Visibility = Visibility . Visible ;
834848 }
835-
849+ VReader . Close ( ) ;
836850 } catch
837851 {
838852
839853 }
854+ try
855+ {
856+ File . Delete ( exe + "\\ tmp\\ Update.txt" ) ;
857+ } catch
858+ {
859+ }
840860 }
841861
842862 private void Start_Update ( object sender , RoutedEventArgs e )
@@ -1177,10 +1197,16 @@ public void doDrag(object sender, MouseEventArgs e)
11771197
11781198 private void Close ( object sender , RoutedEventArgs e )
11791199 {
1180- if ( Directory . Exists ( exe + "\\ tmp" ) ) {
1181- Directory . Delete ( exe + "\\ tmp" , true ) ;
1182- }
11831200 saveInfo ( ) ;
1201+ try
1202+ {
1203+ if ( Directory . Exists ( exe + "\\ tmp" ) )
1204+ {
1205+ Directory . Delete ( exe + "\\ tmp" , true ) ;
1206+ }
1207+ } catch
1208+ {
1209+ }
11841210 this . Close ( ) ;
11851211 }
11861212
0 commit comments