photo_main.js
1.22 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
const {exec} = require('child_process');
const { ipcRenderer } = require("electron");
var fs = require('fs');
var mysql = require('mysql');
//mysql 연동
var connection = mysql.createConnection({
user:'root',
password:'1234',
database : 'dataextraction'
})
var testFolder = './';
fs.readdir(testFolder, function(error, filelist){
const index = filelist.indexOf("photos");
if(index == -1){
photo_extract();
}
else{
ipcRenderer.send("print", "already pulled");
}
})
function photo_extract(){
connection.connect();
connection.query('SELECT path FROM photo', function(error, results, fields){
if(error){
}
if(results.length>0){
var path = new String();
path = results[0].path;
var num = path.indexOf("DCIM");
folder_path = path.substring(0, num+4);
//var folder_path = "/storage/emulated/0/DCIM"; //test용 path
exec("adb pull "+folder_path+" ./photos", (error, stdout, stderr)=>{
if(error){
ipcRenderer.send("print", "please connect the smartphone with PC");
}
else{
ipcRenderer.send("print", "succes");
}
});
}
});
}