summaryrefslogtreecommitdiff
path: root/client.js
diff options
context:
space:
mode:
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);}
});
}