Fixes
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d0e7ef8f47
commit
9bb264da38
|
@ -83,7 +83,7 @@ module.exports = Self => {
|
||||||
const AdmZip = require('adm-zip');
|
const AdmZip = require('adm-zip');
|
||||||
console.log(paths.remoteFile);
|
console.log(paths.remoteFile);
|
||||||
console.log(paths.tempFile);
|
console.log(paths.tempFile);
|
||||||
console.log('Exists temp file: ', fs.existsSync(paths.tempFile))
|
console.log('Exists temp file: ', fs.existsSync(paths.tempFile));
|
||||||
const zip = new AdmZip(paths.tempFile);
|
const zip = new AdmZip(paths.tempFile);
|
||||||
const entries = zip.getEntries();
|
const entries = zip.getEntries();
|
||||||
|
|
||||||
|
@ -102,6 +102,13 @@ module.exports = Self => {
|
||||||
const toTable = file.toTable;
|
const toTable = file.toTable;
|
||||||
const baseName = file.fileName;
|
const baseName = file.fileName;
|
||||||
|
|
||||||
|
const tableName = `edi.${toTable}`;
|
||||||
|
await Self.rawSql(`DELETE FROM ??`, [tableName], options);
|
||||||
|
|
||||||
|
const tx = await Self.beginTransaction({});
|
||||||
|
try {
|
||||||
|
const options = {transaction: tx};
|
||||||
|
|
||||||
for (const zipEntry of entries) {
|
for (const zipEntry of entries) {
|
||||||
const entryName = zipEntry.entryName;
|
const entryName = zipEntry.entryName;
|
||||||
console.log(`Reading file ${entryName}...`);
|
console.log(`Reading file ${entryName}...`);
|
||||||
|
@ -134,12 +141,6 @@ module.exports = Self => {
|
||||||
|
|
||||||
const rawPath = path.join(paths.tempDir, entryName);
|
const rawPath = path.join(paths.tempDir, entryName);
|
||||||
|
|
||||||
const tx = await Self.beginTransaction({});
|
|
||||||
try {
|
|
||||||
const options = {transaction: tx};
|
|
||||||
|
|
||||||
const tableName = `edi.${toTable}`;
|
|
||||||
await Self.rawSql(`DELETE FROM ??`, [tableName], options);
|
|
||||||
await Self.rawSql(sqlTemplate, [rawPath], options);
|
await Self.rawSql(sqlTemplate, [rawPath], options);
|
||||||
await Self.rawSql(`
|
await Self.rawSql(`
|
||||||
UPDATE edi.fileConfig
|
UPDATE edi.fileConfig
|
||||||
|
@ -148,12 +149,11 @@ module.exports = Self => {
|
||||||
`, [lastUpdated, baseName], options);
|
`, [lastUpdated, baseName], options);
|
||||||
|
|
||||||
tx.commit();
|
tx.commit();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
tx.rollback();
|
tx.rollback();
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`Updated table ${toTable}\n`);
|
console.log(`Updated table ${toTable}\n`);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue