-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathfp.js
More file actions
52 lines (45 loc) · 1.28 KB
/
Copy pathfp.js
File metadata and controls
52 lines (45 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
var http = require('http')
, express = require('express')
, mysql = require('mysql')
, exec = require('child_process').exec;
var fs = require('fs');
var client = mysql.createConnection({
user: 'root',
password: 'wldnd1',
database: 'SIDE'
});
process.on('message', function(msg){
var pPath=null;
var fPath=null;
var cnt = 0;
var count = 0;
var file = msg.file+".c";
fs.realpath('../../'+msg.username+'/'+msg.project, function(err, resolvedPath){
if(err){
throw err;
}
pPath=resolvedPath;
console.log(resolvedPath);
});
var id = setInterval(function(){
cnt ++;
client.query("insert into project (id, title, path) values (?,?,?)", [msg.username, msg.project, pPath]);
if(cnt == 1){
clearInterval(id);
}
},2000);
fs.realpath('../../'+msg.username+'/'+msg.project+'/'+msg.file+".c", function(err, resolvedPath){
if(err){
throw err;
}
fPath=resolvedPath;
console.log(resolvedPath);
});
var iid = setInterval(function(){
count ++;
client.query("insert into file (id, p_title, f_title, path) values (?,?,?,?)", [msg.username, msg.project, file, fPath]);
if(count == 1){
clearInterval(iid);
}
},2000);
});