@officebeats/matrix-iptv-cli 3.2.1 → 3.3.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@officebeats/matrix-iptv-cli",
3
- "version": "3.2.1",
3
+ "version": "3.3.0",
4
4
  "description": "The premium Terminal IPTV Decoder",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -64,9 +64,37 @@ function download(url, dest) {
64
64
  });
65
65
  }
66
66
 
67
- download(releaseUrl, binaryPath)
68
- .then(() => {
67
+ const tempPath = binaryPath + ".tmp";
68
+
69
+ download(releaseUrl, tempPath)
70
+ .then(async () => {
69
71
  console.log(`[+] Download complete.`);
72
+
73
+ // Replace old binary with robustness logic for Windows
74
+ let attempts = 0;
75
+ const maxAttempts = 5;
76
+ while (attempts < maxAttempts) {
77
+ try {
78
+ if (fs.existsSync(binaryPath)) {
79
+ if (os.platform() === "win32") {
80
+ const oldPath = binaryPath + ".old." + Date.now();
81
+ fs.renameSync(binaryPath, oldPath);
82
+ try {
83
+ fs.unlinkSync(oldPath);
84
+ } catch (e) {}
85
+ } else {
86
+ fs.unlinkSync(binaryPath);
87
+ }
88
+ }
89
+ fs.renameSync(tempPath, binaryPath);
90
+ break;
91
+ } catch (e) {
92
+ attempts++;
93
+ if (attempts === maxAttempts) throw e;
94
+ await new Promise((r) => setTimeout(r, 1000));
95
+ }
96
+ }
97
+
70
98
  if (os.platform() !== "win32") {
71
99
  fs.chmodSync(binaryPath, "755");
72
100
  console.log(`[+] Executable permissions set.`);