zet-lib 1.4.24 → 1.4.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/zRoute.js +25 -2
- package/package.json +1 -1
package/lib/zRoute.js
CHANGED
|
@@ -5059,7 +5059,7 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
5059
5059
|
throw Error("Data is locked");
|
|
5060
5060
|
} else {
|
|
5061
5061
|
//delete all files
|
|
5062
|
-
zRoute.deleteFiles(table, results[0]);
|
|
5062
|
+
await zRoute.deleteFiles(table, results[0]);
|
|
5063
5063
|
await connection.delete({ table: table, where: where });
|
|
5064
5064
|
zRoute.modelsCacheRenew(table, company_id);
|
|
5065
5065
|
}
|
|
@@ -5072,7 +5072,7 @@ zRoute.deleteSQL = async (table, id, company_id) => {
|
|
|
5072
5072
|
}
|
|
5073
5073
|
};
|
|
5074
5074
|
|
|
5075
|
-
zRoute.deleteFiles = (table, result) => {
|
|
5075
|
+
zRoute.deleteFiles = async (table, result) => {
|
|
5076
5076
|
try {
|
|
5077
5077
|
//check if has files then remove it
|
|
5078
5078
|
const MYMODELS = myCache.get("MYMODELS");
|
|
@@ -5093,6 +5093,29 @@ zRoute.deleteFiles = (table, result) => {
|
|
|
5093
5093
|
fs.remove(dir + result[key], () => {});
|
|
5094
5094
|
}
|
|
5095
5095
|
}
|
|
5096
|
+
if (widgets[key].name == "dropbox") {
|
|
5097
|
+
if (result[key]) {
|
|
5098
|
+
let dbx = new Dropbox({
|
|
5099
|
+
accessToken: process.env.DROPBOX_ACCESS_TOKEN,
|
|
5100
|
+
refreshToken: process.env.DROPBOX_REFRESH_TOKEN,
|
|
5101
|
+
clientId: process.env.DROPBOX_CLIENT_ID,
|
|
5102
|
+
clientSecret: process.env.DROPBOX_CLIENT_SECRET,
|
|
5103
|
+
fetch: fetch,
|
|
5104
|
+
});
|
|
5105
|
+
const files = result[key];
|
|
5106
|
+
const dropboxPath = `/${table}/${key}`;
|
|
5107
|
+
for (const file of files) {
|
|
5108
|
+
let filePath = `${dropboxPath}/${file}`;
|
|
5109
|
+
try {
|
|
5110
|
+
await dbx.filesDeleteV2({
|
|
5111
|
+
path: filePath,
|
|
5112
|
+
});
|
|
5113
|
+
} catch (e) {
|
|
5114
|
+
console.log(e);
|
|
5115
|
+
}
|
|
5116
|
+
}
|
|
5117
|
+
}
|
|
5118
|
+
}
|
|
5096
5119
|
}
|
|
5097
5120
|
} catch (e) {
|
|
5098
5121
|
console.log(e);
|