zet-lib 1.4.14 → 1.4.16
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/zAppRouter.js +48 -10
- package/lib/zRoute.js +3 -1
- package/package.json +1 -1
package/lib/zAppRouter.js
CHANGED
|
@@ -1624,13 +1624,14 @@ router.post("/zdropzone-remove", async (req, res) => {
|
|
|
1624
1624
|
fs.mkdirSync(dir, { recursive: true });
|
|
1625
1625
|
}
|
|
1626
1626
|
let filename = `${dirRoot}/public/zdropzone/${userId}/${req.body.file}`;
|
|
1627
|
+
let arr = [];
|
|
1627
1628
|
if (Util.fileExist(filename)) {
|
|
1628
1629
|
await fs.unlink(filename);
|
|
1629
1630
|
if (myCache.has(cacheName)) {
|
|
1630
|
-
arr = myCache.get(
|
|
1631
|
+
arr = myCache.get(cacheName);
|
|
1631
1632
|
}
|
|
1632
1633
|
arr = Util.arrayDelete(arr, body.file);
|
|
1633
|
-
myCache.set(
|
|
1634
|
+
myCache.set(cacheName, arr);
|
|
1634
1635
|
}
|
|
1635
1636
|
res.json("ok");
|
|
1636
1637
|
} catch (e) {
|
|
@@ -2060,7 +2061,6 @@ router.post("/zdropbox-files", handleTokenRefresh, async (req, res) => {
|
|
|
2060
2061
|
`Error getting temporary link: ${error.message}`
|
|
2061
2062
|
);
|
|
2062
2063
|
}
|
|
2063
|
-
|
|
2064
2064
|
const mockFile = {
|
|
2065
2065
|
name: metadata.result.name,
|
|
2066
2066
|
id: metadata.result,
|
|
@@ -2088,15 +2088,53 @@ router.post("/zdropbox-files", handleTokenRefresh, async (req, res) => {
|
|
|
2088
2088
|
res.json(datas);
|
|
2089
2089
|
});
|
|
2090
2090
|
|
|
2091
|
-
|
|
2092
|
-
|
|
2091
|
+
/*
|
|
2092
|
+
let userId = res.locals.userId;
|
|
2093
|
+
let cacheName = req.body.cname.replace("ZUSER___ID", userId);
|
|
2094
|
+
let dir = `${dirRoot}/public/zdropzone/${userId}`;
|
|
2095
|
+
if (!fs.existsSync(dir)) {
|
|
2096
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
2097
|
+
}
|
|
2098
|
+
let filename = `${dirRoot}/public/zdropzone/${userId}/${req.body.file}`;
|
|
2099
|
+
if (Util.fileExist(filename)) {
|
|
2100
|
+
await fs.unlink(filename);
|
|
2101
|
+
if (myCache.has(cacheName)) {
|
|
2102
|
+
arr = myCache.get(name);
|
|
2103
|
+
}
|
|
2104
|
+
arr = Util.arrayDelete(arr, body.file);
|
|
2105
|
+
myCache.set(name, arr);
|
|
2106
|
+
}
|
|
2107
|
+
res.json("ok");
|
|
2108
|
+
*/
|
|
2109
|
+
// Delete file dropbox
|
|
2110
|
+
router.post("/zdropbox-remove/", handleTokenRefresh, async (req, res) => {
|
|
2093
2111
|
try {
|
|
2094
2112
|
let body = req.body;
|
|
2095
|
-
|
|
2096
|
-
const
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2113
|
+
const userId = res.locals.userId;
|
|
2114
|
+
const fileName = body.file;
|
|
2115
|
+
let cname = body.cname.replace("ZUSER___ID", userId);
|
|
2116
|
+
let cacheName = cname;
|
|
2117
|
+
let splits = cname.split("__");
|
|
2118
|
+
let table = splits[2];
|
|
2119
|
+
let field = splits[3];
|
|
2120
|
+
let type = splits[4];
|
|
2121
|
+
const dir = `/temps/${table}/${field}/${userId}`;
|
|
2122
|
+
await ensureFolder(dir);
|
|
2123
|
+
const filePath = `${dir}/${fileName}`;
|
|
2124
|
+
let arr = [];
|
|
2125
|
+
if (myCache.has(cacheName)) {
|
|
2126
|
+
arr = myCache.get(cacheName);
|
|
2127
|
+
}
|
|
2128
|
+
try {
|
|
2129
|
+
await dbx.filesDeleteV2({
|
|
2130
|
+
path: filePath,
|
|
2131
|
+
});
|
|
2132
|
+
arr = Util.arrayDelete(arr, body.file);
|
|
2133
|
+
myCache.set(cacheName, arr);
|
|
2134
|
+
} catch (e) {
|
|
2135
|
+
console.log(e);
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2100
2138
|
res.json({ success: true });
|
|
2101
2139
|
} catch (error) {
|
|
2102
2140
|
console.error("Error deleting file:", error);
|
package/lib/zRoute.js
CHANGED
|
@@ -4846,7 +4846,9 @@ zRoute.updateSQL = async (req, res, table, data, whereData) => {
|
|
|
4846
4846
|
if (!Util.fileExist(path_dest + item)) {
|
|
4847
4847
|
let newItem = time + item;
|
|
4848
4848
|
newArr.push(newItem);
|
|
4849
|
-
|
|
4849
|
+
if (Util.fileExist(path_src + item)) {
|
|
4850
|
+
fs.rename(path_src + item, path_dest + newItem);
|
|
4851
|
+
}
|
|
4850
4852
|
} else {
|
|
4851
4853
|
newArr.push(item);
|
|
4852
4854
|
}
|