summaryrefslogtreecommitdiff
path: root/client.js
diff options
context:
space:
mode:
authortomsmeding <hallo@tomsmeding.nl>2015-12-18 23:45:33 +0100
committertomsmeding <hallo@tomsmeding.nl>2015-12-18 23:45:33 +0100
commit29e461d2b0cdd1b0fa867c4f4b902d393610b909 (patch)
treeccb789b433769ef600d4a54af3a018bfa9c15954 /client.js
parenta90e6e162b910d16320ddbc08f49cff636f4d186 (diff)
improvements
Diffstat (limited to 'client.js')
-rwxr-xr-xclient.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/client.js b/client.js
index 64a0fed..f6c2278 100755
--- a/client.js
+++ b/client.js
@@ -83,8 +83,10 @@ function handleChanges(changes){
if(!namedate)continue;
changes[i].mtime=new Date(changes[i].mtime);
now=new Date();
- if((now-changes[i].mtime)/1000>15||(now-namedate)/1000>15)continue; //15 seconds limit
- sendfile(changes[i].name);
+ if((now-changes[i].mtime)/1000>60||(now-namedate)/1000>60)continue; //1 minute limit
+ setTimeout(function(n){
+ return function(){sendfile(n);};
+ }(changes[i].name),100);
}
}
@@ -151,7 +153,11 @@ function sendfile(fname,retries){
}
}
console.log("Successful upload");
- fs.unlink(fname); //not sync, take your time
+ setTimeout(function(){
+ fs.unlink(fname,function(err){ //not sync, take your time
+ if(err)console.log(err);
+ });
+ },200);
toClipboard.sync(body.trim());
dialog.info(body+"\n(Copied to clipboard.)");
});
@@ -159,7 +165,8 @@ function sendfile(fname,retries){
req.on("error",function(err){
console.log(err);
});
- req.end(fs.readFileSync(fname));
+ try{req.end(fs.readFileSync(fname));}
+ catch(e){console.log(e);}
});
}