Skip to content

Commit

Permalink
sync skip bug / TJS run order
Browse files Browse the repository at this point in the history
  • Loading branch information
hoge1e3 committed Aug 10, 2016
1 parent 0369b47 commit abd4cf7
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 123 deletions.
4 changes: 2 additions & 2 deletions test/jslesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ var FS = require("./SFile.js");
var testHome=FS.get("../www/fs/home/0123/test/");
//var projectSelURL='http://klab.eplang.jp/jslesson/';
//var projectSelURL='http://localhost/?noconcat=true';
var projectSelURL='http://localhost/'
//var projectSelURL='http://klab.eplang.jp/jslesson/'
//var projectSelURL='http://localhost/'
var projectSelURL='http://klab.eplang.jp/jslesson/'
var loggedin=false;
var SLP=500;

Expand Down
1 change: 1 addition & 0 deletions www/js/build.bat
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cd /d %~dp0
rem copy dolittle\lib.js ..\runtime\lib\dtl\lib.js
copy ..\fs\home\devel\devel\JSLKer\js\concat.js ..\fs\Tonyu\Projects\JSLKer\js\concat.js
copy ..\fs\home\devel\devel\JSLKer\js\concat.js ..\runtime\lib\tjs\kernel.js
call r_js -o build_edit.js
call r_js -o build_selPrj.js
pause
4 changes: 2 additions & 2 deletions www/js/build/tjs/TJSBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ function (A,DU,wget,Sync) {
var nn=document.createElement("script");
nn.setAttribute("charset","utf-8");
nn.setAttribute("src",WebSite.runtime+src);
head.appendChild(nn);
body.appendChild(nn);
});
var nn=document.createElement("script");
nn.setAttribute("charset","utf-8");
var ns=this.prj.getNamespace();
nn.appendChild(document.createTextNode("run('"+ns+"."+name+"');"));
head.appendChild(nn);
body.appendChild(nn);
var dstHTMLF=dst.rel(curHTMLFile.name());
dstHTMLF.text("<html>"+html.innerHTML+"</html>");
};
Expand Down
23 changes: 15 additions & 8 deletions www/js/fs2/sync2.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,15 @@ define(["FS","Shell","WebSite","assert","DeferredUtil"],
var user;
var classid;
var localDelta;
// local.json exists / remote.json not exists -> download / no upload -> remote.json did not create
// local.json not exists / remote.json exists -> no download / upload -> local.json did not create
var localDirInfoFile=syncInfoDir.rel("local.json");
var remoteDirInfoFile=syncInfoDir.rel("remote.json");
var lastLocalDirInfo=localDirInfoFile.exists()?localDirInfoFile.obj():{};
var lastRemoteDirInfo=remoteDirInfoFile.exists()?remoteDirInfoFile.obj():{};
status("getLocalDirInfo", req);
var curLocalDirInfo=getLocalDirInfo();
var curRemoteDirInfo;
//if (options.v) sh.echo("last/cur LocalDirInfo",lastLocalDirInfo, curLocalDirInfo);
localDelta=getDelta(lastLocalDirInfo, curLocalDirInfo);
if (options.v) sh.echo("localDelta",localDelta);
Expand All @@ -137,20 +140,21 @@ define(["FS","Shell","WebSite","assert","DeferredUtil"],
type:"get",
url:A(WebSite.url.getDirInfo),
data:req
}).then(F(function n1(curRemoteDirInfo) {
}).then(F(function n1(gd) {
curRemoteDirInfo=gd.data;
var d;
if (options.v) sh.echo("getDirInfo",curRemoteDirInfo);
if (curRemoteDirInfo.NOT_LOGGED_IN) {
if (options.v) sh.echo("getDirInfo",gd);
if (gd.NOT_LOGGED_IN) {
d = new $.Deferred;
setTimeout(function(){
d.reject(Sync.NOT_LOGGED_IN);
}, 0);
return d.promise();
}
user=curRemoteDirInfo.user;
classid=curRemoteDirInfo["class"];
var base=local;//FS.get(curRemoteDirInfo.base);
var remoteDelta=getDelta(lastRemoteDirInfo, curRemoteDirInfo.data);
user=gd.user;
classid=gd["class"];
var base=local;
var remoteDelta=getDelta(lastRemoteDirInfo, curRemoteDirInfo);
if (options.v) sh.echo("remoteDelta",remoteDelta);
var dd=getDeltaDelta(localDelta,remoteDelta);
var o,f,m;
Expand Down Expand Up @@ -187,7 +191,6 @@ define(["FS","Shell","WebSite","assert","DeferredUtil"],
data:req
});
})).then(F(function n2(dlData) {
sh.echo("dlData=",dlData);
//dlData=JSON.parse(dlData);
if (options.v) sh.echo("dlData:",dlData);
var base=local;//FS.get(dlData.base);
Expand Down Expand Up @@ -223,10 +226,14 @@ define(["FS","Shell","WebSite","assert","DeferredUtil"],
if (!downloadSkipped) {
var newLocalDirInfo=getLocalDirInfo();
localDirInfoFile.obj(newLocalDirInfo);
} else {
localDirInfoFile.obj(curLocalDirInfo);
}
if (!uploadSkipped) {
var newRemoteDirInfo=res.data;
remoteDirInfoFile.obj(newRemoteDirInfo);
} else {
remoteDirInfoFile.obj(curRemoteDirInfo);
}
var upds=[];
for (var i in uploads) upds.push(i);
Expand Down
19 changes: 13 additions & 6 deletions www/js/gen/edit_concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -12320,12 +12320,15 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
var user;
var classid;
var localDelta;
// local.json exists / remote.json not exists -> download / no upload -> remote.json did not create
// local.json not exists / remote.json exists -> no download / upload -> local.json did not create
var localDirInfoFile=syncInfoDir.rel("local.json");
var remoteDirInfoFile=syncInfoDir.rel("remote.json");
var lastLocalDirInfo=localDirInfoFile.exists()?localDirInfoFile.obj():{};
var lastRemoteDirInfo=remoteDirInfoFile.exists()?remoteDirInfoFile.obj():{};
status("getLocalDirInfo", req);
var curLocalDirInfo=getLocalDirInfo();
var curRemoteDirInfo;
//if (options.v) sh.echo("last/cur LocalDirInfo",lastLocalDirInfo, curLocalDirInfo);
localDelta=getDelta(lastLocalDirInfo, curLocalDirInfo);
if (options.v) sh.echo("localDelta",localDelta);
Expand All @@ -12335,7 +12338,8 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
type:"get",
url:A(WebSite.url.getDirInfo),
data:req
}).then(F(function n1(curRemoteDirInfo) {
}).then(F(function n1(_curRemoteDirInfo) {
curRemoteDirInfo=_curRemoteDirInfo;
var d;
if (options.v) sh.echo("getDirInfo",curRemoteDirInfo);
if (curRemoteDirInfo.NOT_LOGGED_IN) {
Expand Down Expand Up @@ -12372,11 +12376,11 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
sh.echo("uploads:",uploads);
sh.echo("downloads:",downloads);
}
if (downloads.length==0) {
/*if (downloads.length==0) {
if (options.v) sh.echo("Skip Download");
downloadSkipped=true;
return {data:{},downloadSkipped:true};
}
}*/
var req={base:remote.path(),paths:JSON.stringify(downloads),token:""+Math.random()};
status("getFiles", req);
return $.ajax({
Expand All @@ -12385,7 +12389,6 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
data:req
});
})).then(F(function n2(dlData) {
sh.echo("dlData=",dlData);
//dlData=JSON.parse(dlData);
if (options.v) sh.echo("dlData:",dlData);
var base=local;//FS.get(dlData.base);
Expand All @@ -12403,11 +12406,11 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
delete d.text;
dlf.metaInfo(d);
}
if (Object.keys(uploads).length==0) {
/*if (Object.keys(uploads).length==0) {
if (options.v) sh.echo("Skip Upload");
uploadSkipped=true;
return {uploadSkipped:true};
}
}*/
var req={base:remote.path(),data:JSON.stringify(uploads),token:""+Math.random()};
req.pathInfo=A(WebSite.url.putFiles);
status("putFiles", req);
Expand All @@ -12421,10 +12424,14 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
if (!downloadSkipped) {
var newLocalDirInfo=getLocalDirInfo();
localDirInfoFile.obj(newLocalDirInfo);
} else if (!localDirInfoFile.exists()) {
localDirInfoFile.obj(curLocalDirInfo);
}
if (!uploadSkipped) {
var newRemoteDirInfo=res.data;
remoteDirInfoFile.obj(newRemoteDirInfo);
} else if (!remoteDirInfoFile.exists()) {
remoteDirInfoFile.obj(curRemoteDirInfo);
}
var upds=[];
for (var i in uploads) upds.push(i);
Expand Down
19 changes: 13 additions & 6 deletions www/js/gen/selPrj_concat.js
Original file line number Diff line number Diff line change
Expand Up @@ -11780,12 +11780,15 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
var user;
var classid;
var localDelta;
// local.json exists / remote.json not exists -> download / no upload -> remote.json did not create
// local.json not exists / remote.json exists -> no download / upload -> local.json did not create
var localDirInfoFile=syncInfoDir.rel("local.json");
var remoteDirInfoFile=syncInfoDir.rel("remote.json");
var lastLocalDirInfo=localDirInfoFile.exists()?localDirInfoFile.obj():{};
var lastRemoteDirInfo=remoteDirInfoFile.exists()?remoteDirInfoFile.obj():{};
status("getLocalDirInfo", req);
var curLocalDirInfo=getLocalDirInfo();
var curRemoteDirInfo;
//if (options.v) sh.echo("last/cur LocalDirInfo",lastLocalDirInfo, curLocalDirInfo);
localDelta=getDelta(lastLocalDirInfo, curLocalDirInfo);
if (options.v) sh.echo("localDelta",localDelta);
Expand All @@ -11795,7 +11798,8 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
type:"get",
url:A(WebSite.url.getDirInfo),
data:req
}).then(F(function n1(curRemoteDirInfo) {
}).then(F(function n1(_curRemoteDirInfo) {
curRemoteDirInfo=_curRemoteDirInfo;
var d;
if (options.v) sh.echo("getDirInfo",curRemoteDirInfo);
if (curRemoteDirInfo.NOT_LOGGED_IN) {
Expand Down Expand Up @@ -11832,11 +11836,11 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
sh.echo("uploads:",uploads);
sh.echo("downloads:",downloads);
}
if (downloads.length==0) {
/*if (downloads.length==0) {
if (options.v) sh.echo("Skip Download");
downloadSkipped=true;
return {data:{},downloadSkipped:true};
}
}*/
var req={base:remote.path(),paths:JSON.stringify(downloads),token:""+Math.random()};
status("getFiles", req);
return $.ajax({
Expand All @@ -11845,7 +11849,6 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
data:req
});
})).then(F(function n2(dlData) {
sh.echo("dlData=",dlData);
//dlData=JSON.parse(dlData);
if (options.v) sh.echo("dlData:",dlData);
var base=local;//FS.get(dlData.base);
Expand All @@ -11863,11 +11866,11 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
delete d.text;
dlf.metaInfo(d);
}
if (Object.keys(uploads).length==0) {
/*if (Object.keys(uploads).length==0) {
if (options.v) sh.echo("Skip Upload");
uploadSkipped=true;
return {uploadSkipped:true};
}
}*/
var req={base:remote.path(),data:JSON.stringify(uploads),token:""+Math.random()};
req.pathInfo=A(WebSite.url.putFiles);
status("putFiles", req);
Expand All @@ -11881,10 +11884,14 @@ define('Sync',["FS","Shell","WebSite","assert","DeferredUtil"],
if (!downloadSkipped) {
var newLocalDirInfo=getLocalDirInfo();
localDirInfoFile.obj(newLocalDirInfo);
} else if (!localDirInfoFile.exists()) {
localDirInfoFile.obj(curLocalDirInfo);
}
if (!uploadSkipped) {
var newRemoteDirInfo=res.data;
remoteDirInfoFile.obj(newRemoteDirInfo);
} else if (!remoteDirInfoFile.exists()) {
remoteDirInfoFile.obj(curRemoteDirInfo);
}
var upds=[];
for (var i in uploads) upds.push(i);
Expand Down
4 changes: 2 additions & 2 deletions www/runtime/lib/dtl/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ Object.defineProperty(Array.prototype,"remove",{
enumerable:false,configurable:true,
value:function(obj){
for(var i=0;i<this.length;i++){
if(this[i]==obj){this.removepos(i);i=0;}
if(this[i]===obj){this.removepos(i+1);break;}
}
}
});
Object.defineProperty(Array.prototype,"消す",{
enumerable:false,configurable:true,
value:function(obj){
for(var i=0;i<this.length;i++){
if(this[i]==obj){this.removepos(i);i=0;}
if(this[i]===obj){this.removepos(i+1);break;}
}
}
});
Expand Down
Loading

0 comments on commit abd4cf7

Please sign in to comment.