public string src;
public string new_sha;
public string cur_sha;
- public ResourcesItem(string src, string target)
+ public ResourcesItem(string src, string target, string new_sha)
{
this.target = target;
this.src = src;
- this.new_sha = "";
+ 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()
{
- if (target.contains("*")) {
+ if (this.target.contains("*")) {
return;
}
- var tfn = BuilderApplication.configDirectory() + "/resources/" + target;
- if (!GLib.FileUtils.test (GLib.Path.get_dirname(tfn), FileTest.IS_REGULAR)) {
+ var tfn = BuilderApplication.configDirectory() + "/resources/" + this.target;
+ if (!GLib.FileUtils.test (tfn, FileTest.IS_REGULAR)) {
return;
}
uint8[] data;
+ uint8[] zero = { 0 };
GLib.FileUtils.get_data(tfn, out data);
var file = File.new_for_path (tfn);
"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...
- this.cur_sha = GLib.Checksum.compute_for_data(GLib.ChecksumType.SHA1,
- csdata.data
- );
+ this.cur_sha = GLib.Checksum.compute_for_data(GLib.ChecksumType.SHA1, csdata.data );
}
}
}
public Resources ()
{
+ this.initFiles();
+ }
+
+ public void initFiles()
+ {
string[] avail_files = {
"roodata.json",
"*",
src = "https://api.github.com/repos/roojs/app.Builder.js/contents/resources/" + split[0];
}
- 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;
}
}
+ /**
+ * called on start to check we have all the required files..
+ */
public void checkResources()
{
bool needsload = false;
-
-
- for (var i = 0; i < this.fetch_files.size; i++ ) {
+
+ // 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++ ) {
if (!FileUtils.test(
- BuilderApplication.configDirectory() + "/resources/" + this.fetch_files.get(i).target,
+ BuilderApplication.configDirectory() + "/resources/" + required[i],
FileTest.EXISTS
)) {
needsload = true;
continue;
}
var src = "https://raw.githubusercontent.com/roojs/app.Builder.js/master/resources/" + split[0] + n;
- var add = new ResourcesItem(src, split[0] + n);
- add.new_sha = ob.get_string_member("sha");
+ 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);
}
public void fetchResourceFrom(ResourcesItem item)
{
+ if (item.new_sha != "" && item.new_sha == item.cur_sha) {
+ this.fetchNext();
+ return;
+ }
// fetch...
print("downloading %s \nto : %s\n", item.src,item.target);