Updater is almost done
This commit is contained in:
+1
-1
@@ -1 +1 @@
|
||||
1565
|
||||
1571
|
||||
@@ -132,6 +132,9 @@ class Main extends Sprite
|
||||
#end
|
||||
Paths.assetsTree = new AssetsLibraryList();
|
||||
|
||||
#if UPDATE_CHECKING
|
||||
funkin.updating.UpdateUtil.init();
|
||||
#end
|
||||
CrashHandler.init();
|
||||
Logs.init();
|
||||
Paths.init();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.updating;
|
||||
|
||||
import sys.io.Process;
|
||||
import haxe.zip.Reader;
|
||||
import funkin.system.ZipUtils;
|
||||
import haxe.io.Path;
|
||||
@@ -47,7 +48,7 @@ class AsyncUpdater {
|
||||
|
||||
public function installFiles(files:Array<String>) {
|
||||
progress.step = INSTALLING;
|
||||
progress.files = files.length;
|
||||
progress.files = files.length+1;
|
||||
for(k=>e in files) {
|
||||
var path = '$path$e';
|
||||
progress.curFile = k+1;
|
||||
@@ -57,6 +58,16 @@ class AsyncUpdater {
|
||||
progress.curZipProgress = new ZipProgress();
|
||||
ZipUtils.uncompressZip(reader, './', null, progress.curZipProgress);
|
||||
}
|
||||
|
||||
var progPath = Sys.programPath();
|
||||
var bakFile = '${Path.withoutExtension(progPath)}.bak';
|
||||
if (FileSystem.exists(bakFile))
|
||||
FileSystem.deleteFile(bakFile);
|
||||
FileSystem.rename(progPath, bakFile);
|
||||
FileSystem.rename('$path$executableName', progPath);
|
||||
|
||||
Sys.command('start /B $executableName');
|
||||
openfl.system.System.exit(0);
|
||||
}
|
||||
|
||||
public function downloadFiles() {
|
||||
@@ -82,11 +93,11 @@ class AsyncUpdater {
|
||||
progress.files = 1;
|
||||
progress.step = DOWNLOADING_EXECUTABLE;
|
||||
trace('starting exe download');
|
||||
doFile([exePath], [executableName], function() {
|
||||
// doFile([exePath], [executableName], function() {
|
||||
trace('done, starting installation');
|
||||
installFiles(fileNames);
|
||||
progress.done = true;
|
||||
});
|
||||
// });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package funkin.updating;
|
||||
|
||||
import sys.FileSystem;
|
||||
import haxe.io.Path;
|
||||
import funkin.github.GitHubRelease;
|
||||
import funkin.github.GitHub;
|
||||
import lime.app.Application;
|
||||
@@ -7,6 +9,15 @@ import lime.app.Application;
|
||||
using funkin.github.GitHub;
|
||||
|
||||
class UpdateUtil {
|
||||
public static function init() {
|
||||
// deletes old bak file if it exists
|
||||
#if sys
|
||||
var bakPath = '${Path.withoutExtension(Sys.programPath())}.bak';
|
||||
if (FileSystem.exists(bakPath))
|
||||
FileSystem.deleteFile(bakPath);
|
||||
#end
|
||||
}
|
||||
|
||||
public static function checkForUpdates():UpdateCheckCallback {
|
||||
var curTag = 'v${Application.current.meta.get('version')}';
|
||||
trace(curTag);
|
||||
|
||||
Reference in New Issue
Block a user