X-Git-Url: http://git.roojs.org/?a=blobdiff_plain;f=src%2FResources.vala;h=f35b38972fc9799cfbd3515fa3ca2886af21cc0c;hb=700f970c58ea880664ac6d459472b93dab1c41f4;hp=5aab7f6b99402704d92a5568e414c2849f15bad9;hpb=21ea01e842f66d6abe1817dd773831bfba796a3c;p=app.Builder.js diff --git a/src/Resources.vala b/src/Resources.vala index 5aab7f6b9..f35b38972 100644 --- a/src/Resources.vala +++ b/src/Resources.vala @@ -26,7 +26,7 @@ public class ResourcesItem : Object { this.new_sha = new_sha; this.cur_sha = ""; this.update_cur_sha(); - print("New ResourcesItem %s (%s) => %s\n", target , this.cur_sha ,src); + print("New ResourcesItem %s (%s) => (%s) %s\n", target , this.cur_sha , new_sha, src); } public void update_cur_sha() { @@ -38,6 +38,7 @@ public class ResourcesItem : Object { return; } uint8[] data; + uint8[] zero = { 0 }; GLib.FileUtils.get_data(tfn, out data); var file = File.new_for_path (tfn); @@ -46,7 +47,8 @@ public class ResourcesItem : Object { "standard::*", FileQueryInfoFlags.NONE ); - var csdata = new GLib.ByteArray.take("blob %s\0".printf(info.get_size().to_string()).data); + var csdata = new GLib.ByteArray.take("blob %s".printf(info.get_size().to_string()).data); + csdata.append(zero); csdata.append(data); // git method... blob %d\0...string... @@ -59,7 +61,7 @@ public class ResourcesItem : Object { public class Resources : Object { - public signal void updateProgress(uint cur_pos); + public signal void updateProgress(uint cur_pos, uint total); static Resources singleton_val; @@ -77,11 +79,17 @@ public class Resources : Object } public Resources () { + this.initFiles(); + } + + public void initFiles() + { string[] avail_files = { "roodata.json", "*", - "Editors/*.js" + "Editors/*.js", + "vapi/*" }; this.fetch_files = new Gee.ArrayList(); @@ -95,21 +103,25 @@ public class Resources : Object } if (target.contains("*")) { var split = target.split("*"); + src = "https://api.github.com/repos/roojs/app.Builder.js/contents/resources/" + split[0]; + if (split[0] == "vapi/") { + src = "https://api.github.com/repos/roojs/app.Builder.js/contents/src/vapi"; + + } + } - this.fetch_files.add(new ResourcesItem(src,target)); + this.fetch_files.add(new ResourcesItem(src,target, "")); } - - - - } - + + } int fetch_pos = 0; public void fetchStart() { + this.initFiles(); if (this.fetch_pos > 0) { // only fetch one at a time... return; } @@ -121,11 +133,11 @@ public class Resources : Object { var cur = this.fetch_pos; this.fetch_pos++; - this.updateProgress(this.fetch_pos); // min=0; + this.updateProgress(this.fetch_pos, this.fetch_files.size); // min=0; if (this.fetch_pos > this.fetch_files.size) { - this.updateProgress(0); + this.updateProgress(0,0); this.fetch_pos = 0; return; @@ -135,17 +147,29 @@ public class Resources : Object } + /** + * called on start to check we have all the required files.. + */ public void checkResources() { bool needsload = false; - + + // this has to check the required files, not the list... + string[] required = { + "bootstrap.builder.html", + "Gir.overides", + "GtkUsage.txt", + "mailer.builder.html", + "roo.builder.html", + "roo.builder.js", + "roodata.json", + "RooUsage.txt" + }; + + for (var i = 0; i < required.length; i++ ) { - for (var i = 0; i < this.fetch_files.size; i++ ) { - if (this.fetch_files.get(i).target.contains("*")) { - continue; - } if (!FileUtils.test( - BuilderApplication.configDirectory() + "/resources/" + this.fetch_files.get(i).target, + BuilderApplication.configDirectory() + "/resources/" + required[i], FileTest.EXISTS )) { needsload = true; @@ -159,6 +183,7 @@ public class Resources : Object public void parseDirectory(string json, string target) { + print("%s\n", json); var pa = new Json.Parser(); pa.load_from_data(json); var node = pa.get_root(); @@ -182,7 +207,11 @@ public class Resources : Object if (this.files_has_target(split[0] + n)) { continue; } - var src = "https://raw.githubusercontent.com/roojs/app.Builder.js/master/resources/" + split[0] + n; + + + + var src = ob.get_string_member("download_url"); + // "https://raw.githubusercontent.com/roojs/app.Builder.js/master/resources/" + split[0] + n; var add = new ResourcesItem(src, split[0] + n, ob.get_string_member("sha") ); //add.new_sha = ob.get_string_member("sha"); this.fetch_files.add(add);