-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipc-install-verify.js
105 lines (81 loc) · 2.81 KB
/
ipc-install-verify.js
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const fs = require('fs').promises;
const IPCDBLib = require("./lib/ipcdb-lib.js");
const IPCGif = require("./lib/ipc-gif.js");
const IPCCard = require("./lib/ipc-card.js");
const GIF_DIR = "react/build/sprites/";
const CARD_DIR = "react/build/cards/";
const start = async function()
{
let session = await IPCDBLib.ipcdb_connect();
if (session == null)
{
console.log("IPCDB_RESTOREDB_FAILED_1");
IPCDBLib.ipcdb_error("IPCDB_RESTOREDB_FAILED");
process.exit();
return IPCDB_ERROR;
}
let client = session.client;
let query = "SELECT token_id FROM ipc_list"
let rows = await client.query(
{ text: query, rowMode: "array" })
.then(res => res.rows)
.catch(err => null);
if (rows == null)
{
IPCDBLib.ipcdb_error("IPCDB_DBIPCLIST_ERROR");
return null;
}
ipc_in_db = rows;
for (let id in ipc_in_db)
{
let ipc_id = ipc_in_db[id];
//check for sprites
let filenameGIF = ipc_id;
filenameGIF = await fs.access(GIF_DIR + filenameGIF + ".gif").then(res => filenameGIF).catch(err => "");
//check for cards
let filenameCard = ipc_id;
filenameCard = await fs.access(CARD_DIR + filenameCard + ".jpg").then(res => filenameCard).catch(err => "");
if (filenameGIF == "" || filenameCard == "")
{
query = "SELECT * FROM ipc_list WHERE token_id = " +ipc_in_db[id];
let ipc_row = await client.query({ text: query, rowMode: "array" }).then(res => res.rows).catch(err => null);
if(ipc_row == null)
{
console.log("IPC_DB_ERROR");
process.exit();
}
let ipc = IPCDBLib.ipcdb_array_to_ipc(ipc_row[0]);
if(filenameGIF == "")
{
//Generate ipc gif
let result = await IPCGif.ipcgif_store(ipc);
if(result == "")
{
console.log("ERROR GENERATING " +GIF_DIR+ipc.token_id+".gif");
process.exit();
}
else
{
//console.log("GENERATED : " +result +".gif");
}
}
if (filenameCard == "")
{
//generate ipc card
let result = await IPCCard.ipccard_store(ipc);
if(result == "")
{
console.log("ERROR GENERATING " +CARD_DIR+ipc.token_id+".jpg");
process.exit();
}
else
{
//console.log("GENERATED : " +result +".jpg");
}
}
}
}
console.log("CHECK COMPLETE");
process.exit();
}
start();