@iobroker/socket-classes 0.2.0 → 0.3.1
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/README.md +9 -0
- package/lib/socketCommands.js +35 -3
- package/lib/socketCommandsAdmin.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -69,6 +69,15 @@ io.close();
|
|
|
69
69
|
-->
|
|
70
70
|
|
|
71
71
|
## Changelog
|
|
72
|
+
### 0.3.1 (2022-05-16)
|
|
73
|
+
* (bluefox) Added back compatibility with js-controller@4.0 for `writeDirAsZip`
|
|
74
|
+
|
|
75
|
+
### 0.3.0 (2022-05-16)
|
|
76
|
+
* (bluefox) Process `writeDirAsZip` locally
|
|
77
|
+
|
|
78
|
+
### 0.2.1 (2022-05-12)
|
|
79
|
+
* (bluefox) fixed `getObjects` command
|
|
80
|
+
|
|
72
81
|
### 0.2.0 (2022-05-09)
|
|
73
82
|
* (bluefox) fixed `delObjects` command
|
|
74
83
|
|
package/lib/socketCommands.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
let axios = null;
|
|
2
|
+
let zipFiles;
|
|
2
3
|
|
|
3
4
|
// taken from here: https://github.com/ioBroker/ioBroker.js-controller/blob/master/packages/common/src/lib/common/tools.ts#L2386
|
|
4
5
|
/**
|
|
@@ -79,6 +80,7 @@ class SocketCommands {
|
|
|
79
80
|
this.adapter = adapter;
|
|
80
81
|
this.commands = {};
|
|
81
82
|
this.subscribes = {};
|
|
83
|
+
this.logEnabled = false;
|
|
82
84
|
|
|
83
85
|
this._updateSession = updateSession;
|
|
84
86
|
|
|
@@ -287,7 +289,10 @@ class SocketCommands {
|
|
|
287
289
|
} else if (type === 'objectChange') {
|
|
288
290
|
this.adapter.subscribeForeignObjects && this.adapter.subscribeForeignObjects(pattern);
|
|
289
291
|
} else if (type === 'log') {
|
|
290
|
-
this.
|
|
292
|
+
if (!this.logEnabled && this.adapter.requireLog) {
|
|
293
|
+
this.logEnabled = true;
|
|
294
|
+
this.adapter.requireLog(true);
|
|
295
|
+
}
|
|
291
296
|
} else if (type === 'fileChange') {
|
|
292
297
|
this.adapter.subscribeForeignFiles && this.adapter.subscribeForeignFiles(pattern, patternFile);
|
|
293
298
|
}
|
|
@@ -331,7 +336,10 @@ class SocketCommands {
|
|
|
331
336
|
this.adapter.unsubscribeForeignObjects && this.adapter.unsubscribeForeignObjects(pattern);
|
|
332
337
|
} else if (type === 'log') {
|
|
333
338
|
//console.log((socket._name || socket.id) + ' requireLog false');
|
|
334
|
-
this.
|
|
339
|
+
if (this.logEnabled && this.adapter.requireLog) {
|
|
340
|
+
this.logEnabled = false;
|
|
341
|
+
this.adapter.requireLog(false);
|
|
342
|
+
}
|
|
335
343
|
} else if (type === 'fileChange') {
|
|
336
344
|
//console.log((socket._name || socket.id) + ' requireLog false');
|
|
337
345
|
this.adapter.unsubscribeForeignFiles && this.adapter.unsubscribeForeignFiles(pattern, patternFile);
|
|
@@ -613,7 +621,31 @@ class SocketCommands {
|
|
|
613
621
|
if (this.sendToHost) {
|
|
614
622
|
this.sendToHost(host, command, message, callback);
|
|
615
623
|
} else {
|
|
616
|
-
this
|
|
624
|
+
// Try to decode this file locally as redis has a limitation for files bigger than 20MB
|
|
625
|
+
if (command === 'writeDirAsZip' && message && message.data.length > 1024 * 1024) {
|
|
626
|
+
if (!zipFiles) {
|
|
627
|
+
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
|
|
628
|
+
zipFiles = require(utils.controllerDir + '/lib/zipFiles.js');
|
|
629
|
+
}
|
|
630
|
+
zipFiles
|
|
631
|
+
.writeDirAsZip(
|
|
632
|
+
this.adapter, // normally we have to pass here the internal "objects" object, but as
|
|
633
|
+
// only writeFile is used, and it has the same name we can pass here the
|
|
634
|
+
// adapter, which has the function with the same name and arguments
|
|
635
|
+
message.id,
|
|
636
|
+
message.name,
|
|
637
|
+
Buffer.from(message.data, 'base64'),
|
|
638
|
+
message.options,
|
|
639
|
+
error => callback({ error }) // this is for back compatibility with js-controller@4.0 or older
|
|
640
|
+
)
|
|
641
|
+
.then(() => callback({}))
|
|
642
|
+
.catch(error => {
|
|
643
|
+
this.adapter.log.error(`Cannot write zip file as folder: ${error}`);
|
|
644
|
+
callback({ error });
|
|
645
|
+
});
|
|
646
|
+
} else {
|
|
647
|
+
this.adapter.sendToHost(host, command, message, callback);
|
|
648
|
+
}
|
|
617
649
|
}
|
|
618
650
|
}
|
|
619
651
|
};
|
|
@@ -143,6 +143,7 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
143
143
|
icon: obj.common.icon,
|
|
144
144
|
materialize: obj.common.materialize,
|
|
145
145
|
jsonConfig: obj.common.jsonConfig,
|
|
146
|
+
version: obj.common.version,
|
|
146
147
|
};
|
|
147
148
|
if (isTab) {
|
|
148
149
|
config.tab = true;
|
|
@@ -1111,9 +1112,10 @@ class SocketCommandsAdmin extends SocketCommands {
|
|
|
1111
1112
|
__initCommandsObjects() {
|
|
1112
1113
|
super.__initCommandsObjects();
|
|
1113
1114
|
|
|
1114
|
-
this.commands['getAllObjects'] = (socket, callback) =>
|
|
1115
|
-
|
|
1116
|
-
|
|
1115
|
+
this.commands['getAllObjects'] = (socket, callback) => this._getAllObjects(socket, callback);
|
|
1116
|
+
|
|
1117
|
+
// Identical to getAllObjects
|
|
1118
|
+
this.commands['getObjects'] = (socket, callback) => this._getAllObjects(socket, callback);
|
|
1117
1119
|
|
|
1118
1120
|
this.commands['extendObject'] = (socket, id, obj, callback) => {
|
|
1119
1121
|
if (this._checkPermissions(socket, 'extendObject', callback, id)) {
|