Browse Source

fix: create meta folder if missing(meta export), show error on failure

re #924 #923

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/927/head
Pranav C 3 years ago
parent
commit
bb923c08d8
  1. 13
      packages/nc-gui/store/sqlMgr.js
  2. 19
      packages/nocodb/package-lock.json
  3. 1
      packages/nocodb/package.json
  4. 8
      packages/nocodb/src/lib/migrator/SqlMigrator/lib/KnexMigrator.ts
  5. 7
      packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

13
packages/nc-gui/store/sqlMgr.js

@ -426,8 +426,17 @@ export const actions = {
return data return data
} catch (e) { } catch (e) {
console.log(e) let msg
const err = new Error(e.response.data.msg) if (e.response.data instanceof Blob) {
try {
msg = JSON.parse(await e.response.data.text()).msg
} catch {
msg = 'Some internal error occurred'
}
} else {
msg = e.response.data.msg || 'Some internal error occurred'
}
const err = new Error(msg)
err.response = e.response err.response = e.response
throw err throw err
} }

19
packages/nocodb/package-lock.json generated

@ -105,6 +105,7 @@
"@types/inflection": "^1.5.28", "@types/inflection": "^1.5.28",
"@types/lru-cache": "^5.1.0", "@types/lru-cache": "^5.1.0",
"@types/minio": "^7.0.7", "@types/minio": "^7.0.7",
"@types/mkdirp": "^1.0.2",
"@types/mocha": "^8.0.1", "@types/mocha": "^8.0.1",
"@types/nodemailer": "^6.4.0", "@types/nodemailer": "^6.4.0",
"@types/supertest": "^2.0.10", "@types/supertest": "^2.0.10",
@ -1836,6 +1837,15 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"node_modules/@types/mkdirp": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-1.0.2.tgz",
"integrity": "sha512-o0K1tSO0Dx5X6xlU5F1D6625FawhC3dU3iqr25lluNv/+/QIVH8RLNEiVokgIZo+mz+87w/3Mkg/VvQS+J51fQ==",
"dev": true,
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/mocha": { "node_modules/@types/mocha": {
"version": "8.2.3", "version": "8.2.3",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz",
@ -26086,6 +26096,15 @@
"@types/node": "*" "@types/node": "*"
} }
}, },
"@types/mkdirp": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@types/mkdirp/-/mkdirp-1.0.2.tgz",
"integrity": "sha512-o0K1tSO0Dx5X6xlU5F1D6625FawhC3dU3iqr25lluNv/+/QIVH8RLNEiVokgIZo+mz+87w/3Mkg/VvQS+J51fQ==",
"dev": true,
"requires": {
"@types/node": "*"
}
},
"@types/mocha": { "@types/mocha": {
"version": "8.2.3", "version": "8.2.3",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-8.2.3.tgz",

1
packages/nocodb/package.json

@ -186,6 +186,7 @@
"@types/inflection": "^1.5.28", "@types/inflection": "^1.5.28",
"@types/lru-cache": "^5.1.0", "@types/lru-cache": "^5.1.0",
"@types/minio": "^7.0.7", "@types/minio": "^7.0.7",
"@types/mkdirp": "^1.0.2",
"@types/mocha": "^8.0.1", "@types/mocha": "^8.0.1",
"@types/nodemailer": "^6.4.0", "@types/nodemailer": "^6.4.0",
"@types/supertest": "^2.0.10", "@types/supertest": "^2.0.10",

8
packages/nocodb/src/lib/migrator/SqlMigrator/lib/KnexMigrator.ts

@ -122,6 +122,8 @@ export default class KnexMigrator extends SqlMigrator {
); );
try { try {
// @ts-ignore
// @ts-ignore
await promisify(mkdirp)( await promisify(mkdirp)(
path.join( path.join(
this.toolDir, this.toolDir,
@ -142,6 +144,7 @@ export default class KnexMigrator extends SqlMigrator {
) )
); );
// @ts-ignore
await promisify(mkdirp)( await promisify(mkdirp)(
path.join( path.join(
this.toolDir, this.toolDir,
@ -163,6 +166,7 @@ export default class KnexMigrator extends SqlMigrator {
) )
); );
// @ts-ignore
await promisify(mkdirp)( await promisify(mkdirp)(
path.join( path.join(
this.toolDir, this.toolDir,
@ -183,6 +187,7 @@ export default class KnexMigrator extends SqlMigrator {
) )
); );
// @ts-ignore
await promisify(mkdirp)( await promisify(mkdirp)(
path.join( path.join(
this.toolDir, this.toolDir,
@ -202,6 +207,7 @@ export default class KnexMigrator extends SqlMigrator {
) )
); );
// @ts-ignore
await promisify(mkdirp)( await promisify(mkdirp)(
path.join( path.join(
this.toolDir, this.toolDir,
@ -211,6 +217,7 @@ export default class KnexMigrator extends SqlMigrator {
) )
); );
// @ts-ignore
await promisify(mkdirp)( await promisify(mkdirp)(
path.join( path.join(
this.toolDir, this.toolDir,
@ -346,6 +353,7 @@ export default class KnexMigrator extends SqlMigrator {
//freshProject.folder = args.folder; //freshProject.folder = args.folder;
// @ts-ignore
await promisify(mkdirp)(`${args.folder}`); await promisify(mkdirp)(`${args.folder}`);
this.emit(`Project folder created successfully: ${args.folder}`); this.emit(`Project folder created successfully: ${args.folder}`);

7
packages/nocodb/src/lib/noco/meta/NcMetaMgr.ts

@ -1,5 +1,6 @@
import CryptoJS from 'crypto-js'; import CryptoJS from 'crypto-js';
import fs from 'fs'; import fs from 'fs';
import mkdirp from 'mkdirp';
import path from 'path'; import path from 'path';
import archiver from 'archiver'; import archiver from 'archiver';
@ -700,8 +701,11 @@ export default class NcMetaMgr {
args.dbAlias, args.dbAlias,
'meta' 'meta'
); );
mkdirp.sync(metaFolder);
// const client = await this.projectGetSqlClient(args); // const client = await this.projectGetSqlClient(args);
const dbAlias = await this.getDbAlias(args); const dbAlias = this.getDbAlias(args);
for (const tn of META_TABLES[this.config.projectType.toLowerCase()]) { for (const tn of META_TABLES[this.config.projectType.toLowerCase()]) {
// const metaData = await client.knex(tn).select(); // const metaData = await client.knex(tn).select();
const metaData = await this.xcMeta.metaList(projectId, dbAlias, tn); const metaData = await this.xcMeta.metaList(projectId, dbAlias, tn);
@ -730,6 +734,7 @@ export default class NcMetaMgr {
}); });
} catch (e) { } catch (e) {
console.log(e); console.log(e);
throw e;
} }
} }
} }

Loading…
Cancel
Save