@trap_stevo/filetide 0.0.21 → 0.0.23
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/dist/cjs/FileTide.js
CHANGED
|
@@ -244,7 +244,7 @@ function _setupFileEventListeners(userID, client, onIncomingFile) {
|
|
|
244
244
|
totalChunks: data.totalChunks,
|
|
245
245
|
fileInfo: data
|
|
246
246
|
});
|
|
247
|
-
const saveDir =
|
|
247
|
+
const saveDir = FileUtilityManager.osPath(data.path);
|
|
248
248
|
if (!fs.existsSync(saveDir)) {
|
|
249
249
|
fs.mkdirSync(saveDir, {
|
|
250
250
|
recursive: true
|
|
@@ -274,7 +274,7 @@ function _setupFileEventListeners(userID, client, onIncomingFile) {
|
|
|
274
274
|
if (!transferState) {
|
|
275
275
|
return;
|
|
276
276
|
}
|
|
277
|
-
const savePath = path.join(data.filePath, data.fileName);
|
|
277
|
+
const savePath = FileUtilityManager.osPath(path.join(data.filePath, data.fileName));
|
|
278
278
|
const fullFile = Buffer.concat(transferState.receivedChunks);
|
|
279
279
|
fs.writeFileSync(savePath, fullFile);
|
|
280
280
|
console.log(`[${userID}] File saved at : ${savePath}`);
|
|
@@ -32,6 +32,15 @@ class FileUtilityManager {
|
|
|
32
32
|
static normalizePath(inputPath) {
|
|
33
33
|
return path.normalize(inputPath);
|
|
34
34
|
}
|
|
35
|
+
static osPath(filePath) {
|
|
36
|
+
let resolvedPath = path.resolve(filePath);
|
|
37
|
+
if (resolvedPath.startsWith("\\\\")) {
|
|
38
|
+
return resolvedPath.replace(/\\/g, "/").replace(/^\/{2,}/, "//");
|
|
39
|
+
}
|
|
40
|
+
resolvedPath = resolvedPath.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
41
|
+
resolvedPath = resolvedPath.replace(/\\/g, "/");
|
|
42
|
+
return resolvedPath;
|
|
43
|
+
}
|
|
35
44
|
|
|
36
45
|
/**
|
|
37
46
|
* Gets all files' data from a given directory.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trap_stevo/filetide",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.23",
|
|
4
4
|
"description": "Revolutionizing real-time file transfer with seamless, instant communication across any device. Deliver files instantly, regardless of platform, and experience unparalleled speed and control in managing transfers. Elevate your file-sharing capabilities with a tool designed for precision, efficiency, and effortless connectivity.",
|
|
5
5
|
"main": "dist/cjs/FileTide.js",
|
|
6
6
|
"scripts": {
|