node-opcua-file-transfer 2.178.0 → 2.180.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/dist/client/client_file.d.ts +4 -4
- package/dist/client/client_file.js +30 -27
- package/dist/client/client_file.js.map +1 -1
- package/dist/client/read_file.d.ts +1 -1
- package/dist/client/read_file.js +1 -1
- package/dist/client/read_file.js.map +1 -1
- package/dist/client/read_max_byte_string_length.d.ts +1 -1
- package/dist/client/read_max_byte_string_length.js.map +1 -1
- package/dist/client/write_file.d.ts +1 -1
- package/dist/client/write_file.js +4 -3
- package/dist/client/write_file.js.map +1 -1
- package/dist/common/abstract_fs.d.ts +1 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/open_mode.js +7 -0
- package/dist/open_mode.js.map +1 -1
- package/dist/server/file_type_helpers.d.ts +3 -3
- package/dist/server/file_type_helpers.js +36 -34
- package/dist/server/file_type_helpers.js.map +1 -1
- package/package.json +24 -24
- package/source/client/client_file.ts +38 -35
- package/source/client/read_file.ts +2 -4
- package/source/client/read_max_byte_string_length.ts +2 -5
- package/source/client/write_file.ts +5 -6
- package/source/common/abstract_fs.ts +2 -4
- package/source/index.ts +1 -1
- package/source/open_mode.ts +9 -2
- package/source/server/file_type_helpers.ts +37 -44
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-file-transfer
|
|
3
3
|
*/
|
|
4
|
-
import { Int32, Int64, UInt16, UInt32, UInt64 } from "node-opcua-basic-types";
|
|
5
|
-
import { QualifiedName } from "node-opcua-data-model";
|
|
6
|
-
import { NodeId } from "node-opcua-nodeid";
|
|
7
|
-
import { IBasicSessionAsync } from "node-opcua-pseudo-session";
|
|
4
|
+
import { type Int32, type Int64, type UInt16, type UInt32, type UInt64 } from "node-opcua-basic-types";
|
|
5
|
+
import { type QualifiedName } from "node-opcua-data-model";
|
|
6
|
+
import { type NodeId } from "node-opcua-nodeid";
|
|
7
|
+
import type { IBasicSessionAsync } from "node-opcua-pseudo-session";
|
|
8
8
|
import { OpenFileMode } from "../open_mode";
|
|
9
9
|
export { OpenFileMode } from "../open_mode";
|
|
10
10
|
export interface IClientFile {
|
|
@@ -5,12 +5,12 @@ exports.ClientFile = exports.OpenFileMode = void 0;
|
|
|
5
5
|
* @module node-opcua-file-transfer
|
|
6
6
|
*/
|
|
7
7
|
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
8
|
+
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
8
9
|
const node_opcua_data_model_1 = require("node-opcua-data-model");
|
|
10
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
9
11
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
10
12
|
const node_opcua_service_translate_browse_path_1 = require("node-opcua-service-translate-browse-path");
|
|
11
13
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
12
|
-
const node_opcua_constants_1 = require("node-opcua-constants");
|
|
13
|
-
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
14
14
|
const debugLog = (0, node_opcua_debug_1.make_debugLog)("FileType");
|
|
15
15
|
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)("FileType");
|
|
16
16
|
const open_mode_1 = require("../open_mode");
|
|
@@ -49,7 +49,7 @@ class ClientFile {
|
|
|
49
49
|
}
|
|
50
50
|
async open(mode) {
|
|
51
51
|
if (mode === null || mode === undefined) {
|
|
52
|
-
throw new Error(
|
|
52
|
+
throw new Error(`expecting a validMode ${open_mode_1.OpenFileMode[mode]}`);
|
|
53
53
|
}
|
|
54
54
|
if (this.fileHandle) {
|
|
55
55
|
throw new Error("File has already be opened");
|
|
@@ -61,10 +61,11 @@ class ClientFile {
|
|
|
61
61
|
objectId: this.nodeId
|
|
62
62
|
});
|
|
63
63
|
if (result.statusCode.isNotGood()) {
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
// c8 ignore next
|
|
65
|
+
doDebug && debugLog("Cannot open file : ");
|
|
66
|
+
throw new Error(`cannot open file statusCode = ${result.statusCode.toString()} mode = ${open_mode_1.OpenFileMode[mode]}`);
|
|
66
67
|
}
|
|
67
|
-
this.fileHandle = result.outputArguments[0].value;
|
|
68
|
+
this.fileHandle = result.outputArguments?.[0].value;
|
|
68
69
|
return this.fileHandle;
|
|
69
70
|
}
|
|
70
71
|
async close() {
|
|
@@ -78,8 +79,9 @@ class ClientFile {
|
|
|
78
79
|
objectId: this.nodeId
|
|
79
80
|
});
|
|
80
81
|
if (result.statusCode.isNotGood()) {
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
// c8 ignore next
|
|
83
|
+
doDebug && debugLog("Cannot close file : ");
|
|
84
|
+
throw new Error(`cannot close file statusCode = ${result.statusCode.toString()}`);
|
|
83
85
|
}
|
|
84
86
|
this.fileHandle = 0;
|
|
85
87
|
}
|
|
@@ -94,9 +96,9 @@ class ClientFile {
|
|
|
94
96
|
objectId: this.nodeId
|
|
95
97
|
});
|
|
96
98
|
if (result.statusCode.isNotGood()) {
|
|
97
|
-
throw new Error(
|
|
99
|
+
throw new Error(`Error ${result.statusCode.toString()}`);
|
|
98
100
|
}
|
|
99
|
-
return result.outputArguments[0].value;
|
|
101
|
+
return result.outputArguments?.[0].value;
|
|
100
102
|
}
|
|
101
103
|
async setPosition(position) {
|
|
102
104
|
await this.ensureInitialized();
|
|
@@ -119,7 +121,7 @@ class ClientFile {
|
|
|
119
121
|
objectId: this.nodeId
|
|
120
122
|
});
|
|
121
123
|
if (result.statusCode.isNotGood()) {
|
|
122
|
-
throw new Error(
|
|
124
|
+
throw new Error(`Error ${result.statusCode.toString()}`);
|
|
123
125
|
}
|
|
124
126
|
return;
|
|
125
127
|
}
|
|
@@ -141,12 +143,12 @@ class ClientFile {
|
|
|
141
143
|
objectId: this.nodeId
|
|
142
144
|
});
|
|
143
145
|
if (result.statusCode.isNotGood()) {
|
|
144
|
-
throw new Error(
|
|
146
|
+
throw new Error(`Error ${result.statusCode.toString()}`);
|
|
145
147
|
}
|
|
146
148
|
if (!result.outputArguments || result.outputArguments[0].dataType !== node_opcua_variant_1.DataType.ByteString) {
|
|
147
149
|
throw new Error("Error invalid output");
|
|
148
150
|
}
|
|
149
|
-
return result.outputArguments[0].value;
|
|
151
|
+
return result.outputArguments?.[0].value;
|
|
150
152
|
}
|
|
151
153
|
async write(data) {
|
|
152
154
|
await this.ensureInitialized();
|
|
@@ -166,7 +168,7 @@ class ClientFile {
|
|
|
166
168
|
objectId: this.nodeId
|
|
167
169
|
});
|
|
168
170
|
if (result.statusCode.isNotGood()) {
|
|
169
|
-
throw new Error(
|
|
171
|
+
throw new Error(`Error ${result.statusCode.toString()}`);
|
|
170
172
|
}
|
|
171
173
|
return;
|
|
172
174
|
}
|
|
@@ -176,7 +178,7 @@ class ClientFile {
|
|
|
176
178
|
const dataValue = await this.session.read(nodeToRead);
|
|
177
179
|
// c8 ignore next
|
|
178
180
|
if (doDebug) {
|
|
179
|
-
debugLog(" OpenCount ", nodeToRead.nodeId
|
|
181
|
+
debugLog(" OpenCount ", nodeToRead.nodeId?.toString(), dataValue.toString());
|
|
180
182
|
}
|
|
181
183
|
return dataValue.value.value;
|
|
182
184
|
}
|
|
@@ -186,10 +188,10 @@ class ClientFile {
|
|
|
186
188
|
const dataValue = await this.session.read(nodeToRead);
|
|
187
189
|
return dataValue.value.value;
|
|
188
190
|
}
|
|
189
|
-
// eslint-disable-next-line max-statements
|
|
190
191
|
async extractMethodsIds() {
|
|
191
192
|
if (ClientFile.useGlobalMethod) {
|
|
192
|
-
|
|
193
|
+
// c8 ignore next
|
|
194
|
+
doDebug && debugLog("Using GlobalMethodId");
|
|
193
195
|
this.openMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Open);
|
|
194
196
|
this.closeMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Close);
|
|
195
197
|
this.setPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_SetPosition);
|
|
@@ -204,8 +206,8 @@ class ClientFile {
|
|
|
204
206
|
if (results[1].statusCode.isNotGood()) {
|
|
205
207
|
throw new Error("fileType object does not expose mandatory Size Property");
|
|
206
208
|
}
|
|
207
|
-
this.openCountNodeId = results[0].targets[0].targetId;
|
|
208
|
-
this.sizeNodeId = results[1].targets[0].targetId;
|
|
209
|
+
this.openCountNodeId = results[0].targets?.[0].targetId;
|
|
210
|
+
this.sizeNodeId = results[1].targets?.[0].targetId;
|
|
209
211
|
return;
|
|
210
212
|
}
|
|
211
213
|
const browsePaths = [
|
|
@@ -243,17 +245,18 @@ class ClientFile {
|
|
|
243
245
|
if (results[7].statusCode.isNotGood()) {
|
|
244
246
|
throw new Error("fileType object does not expose mandatory Size Variable");
|
|
245
247
|
}
|
|
248
|
+
// biome-ignore lint/correctness/noConstantCondition: deliberate debug on/off toggle, not dead code
|
|
246
249
|
if (false && doDebug) {
|
|
247
250
|
results.map((x) => debugLog(x.toString()));
|
|
248
251
|
}
|
|
249
|
-
this.openMethodNodeId = results[0].targets[0].targetId;
|
|
250
|
-
this.closeMethodNodeId = results[1].targets[0].targetId;
|
|
251
|
-
this.setPositionNodeId = results[2].targets[0].targetId;
|
|
252
|
-
this.getPositionNodeId = results[3].targets[0].targetId;
|
|
253
|
-
this.writeNodeId = results[4].targets[0].targetId;
|
|
254
|
-
this.readNodeId = results[5].targets[0].targetId;
|
|
255
|
-
this.openCountNodeId = results[6].targets[0].targetId;
|
|
256
|
-
this.sizeNodeId = results[7].targets[0].targetId;
|
|
252
|
+
this.openMethodNodeId = results[0].targets?.[0].targetId;
|
|
253
|
+
this.closeMethodNodeId = results[1].targets?.[0].targetId;
|
|
254
|
+
this.setPositionNodeId = results[2].targets?.[0].targetId;
|
|
255
|
+
this.getPositionNodeId = results[3].targets?.[0].targetId;
|
|
256
|
+
this.writeNodeId = results[4].targets?.[0].targetId;
|
|
257
|
+
this.readNodeId = results[5].targets?.[0].targetId;
|
|
258
|
+
this.openCountNodeId = results[6].targets?.[0].targetId;
|
|
259
|
+
this.sizeNodeId = results[7].targets?.[0].targetId;
|
|
257
260
|
}
|
|
258
261
|
async ensureInitialized() {
|
|
259
262
|
if (!this.openMethodNodeId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client_file.js","sourceRoot":"","sources":["../../source/client/client_file.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,
|
|
1
|
+
{"version":3,"file":"client_file.js","sourceRoot":"","sources":["../../source/client/client_file.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAA+H;AAC/H,+DAAiD;AACjD,iEAAyE;AACzE,uDAAiE;AACjE,yDAA+D;AAG/D,uGAA2F;AAC3F,2DAAgE;AAEhE,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAE3C,4CAA4C;AAE5C,0CAA4C;AAAnC,yGAAA,YAAY,OAAA;AA2BrB;;;GAGG;AACH,MAAa,UAAU;IACZ,MAAM,CAAC,eAAe,GAAG,KAAK,CAAC;IAE/B,UAAU,GAAG,CAAC,CAAC;IACf,OAAO,CAAqB;IAEnB,MAAM,CAAS;IAEvB,gBAAgB,CAAU;IAC1B,iBAAiB,CAAU;IAC3B,iBAAiB,CAAU;IAC3B,iBAAiB,CAAU;IAC3B,UAAU,CAAU;IACpB,WAAW,CAAU;IACrB,eAAe,CAAU;IACzB,UAAU,CAAU;IAE5B,YAAY,OAA2B,EAAE,MAAc;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,IAAc,UAAU;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,UAAU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,CAAC;QAC1D,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAC1D,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACpD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACvD,CAAC;IAES,KAAK,CAAC,iBAAiB;QAC7B,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACnC,CAAC;IACL,CAAC;;AA5QL,gCA6QC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG"}
|
package/dist/client/read_file.js
CHANGED
|
@@ -4,8 +4,8 @@ exports.readFile = readFile;
|
|
|
4
4
|
exports.readOPCUAFile = readOPCUAFile;
|
|
5
5
|
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
6
6
|
const client_file_1 = require("./client_file");
|
|
7
|
-
const read_max_byte_string_length_1 = require("./read_max_byte_string_length");
|
|
8
7
|
const get_transport_max_size_1 = require("./get_transport_max_size");
|
|
8
|
+
const read_max_byte_string_length_1 = require("./read_max_byte_string_length");
|
|
9
9
|
async function readFile(clientFile, options) {
|
|
10
10
|
options = options || { chunkSize: await (0, read_max_byte_string_length_1.readMaxByteStringLength)(clientFile.session) };
|
|
11
11
|
let maxBlockSize = options.chunkSize || 1024;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read_file.js","sourceRoot":"","sources":["../../source/client/read_file.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"read_file.js","sourceRoot":"","sources":["../../source/client/read_file.ts"],"names":[],"mappings":";;AAKA,4BA+BC;AAED,sCAEC;AAxCD,mEAAqD;AACrD,+CAA+D;AAC/D,qEAA0G;AAC1G,+EAAwE;AAEjE,KAAK,UAAU,QAAQ,CAAC,UAAuB,EAAE,OAAgC;IACpF,OAAO,GAAG,OAAO,IAAI,EAAE,SAAS,EAAE,MAAM,IAAA,qDAAuB,EAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IACtF,IAAI,YAAY,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC;IAC7C,MAAM,gBAAgB,GAAG,IAAA,mDAA0B,EAAC,UAAU,CAAC,OAAwC,CAAC,CAAC;IACzG,YAAY,GAAG,gBAAgB,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;IAE9F,MAAM,UAAU,CAAC,IAAI,CAAC,0BAAY,CAAC,IAAI,CAAC,CAAC;IACzC,IAAI,CAAC;QACD,MAAM,QAAQ,GAAG,IAAA,oCAAW,EAAC,MAAM,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD;;WAEG;QACH,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC;QACrE,IAAI,IAAI,CAAC,MAAM,IAAI,QAAQ,EAAE,CAAC;YAC1B,2BAA2B;YAC3B,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,wCAAwC;QACxC,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,CAAC;QACtB,IAAI,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC;QACvC,OAAO,SAAS,GAAG,CAAC,EAAE,CAAC;YACnB,MAAM,GAAG,GAAG,MAAM,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAC;YACrE,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC;gBAAE,MAAM;YAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACjB,SAAS,IAAI,GAAG,CAAC,MAAM,CAAC;QAC5B,CAAC;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,CAAC;YAAS,CAAC;QACP,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,aAAa,CAAC,UAAuB;IACvD,OAAO,MAAM,QAAQ,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
1
|
+
import type { IBasicSessionReadAsyncSimple } from "node-opcua-pseudo-session";
|
|
2
2
|
export declare function readMaxByteStringLength(session: IBasicSessionReadAsyncSimple): Promise<number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read_max_byte_string_length.js","sourceRoot":"","sources":["../../source/client/read_max_byte_string_length.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"read_max_byte_string_length.js","sourceRoot":"","sources":["../../source/client/read_max_byte_string_length.ts"],"names":[],"mappings":";;AAOA,0DASC;AAhBD,mEAAsD;AACtD,uEAAwD;AACxD,+DAAmD;AACnD,yDAAkD;AAElD,mEAAqD;AAE9C,KAAK,UAAU,uBAAuB,CAAC,OAAqC;IAC/E,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC;QACjC,MAAM,EAAE,IAAA,iCAAa,EAAC,kCAAW,CAAC,6CAA6C,CAAC;QAChF,WAAW,EAAE,qCAAY,CAAC,KAAK;KAClC,CAAC,CAAC;IACH,IAAI,SAAS,CAAC,UAAU,KAAK,oCAAW,CAAC,IAAI,EAAE,CAAC;QAC5C,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,OAAO,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,uCAAY,CAAC,mBAAmB,CAAC;AACrE,CAAC"}
|
|
@@ -10,8 +10,8 @@ const promises_1 = require("node:stream/promises");
|
|
|
10
10
|
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
|
|
11
11
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
12
12
|
const client_file_1 = require("./client_file");
|
|
13
|
-
const read_max_byte_string_length_1 = require("./read_max_byte_string_length");
|
|
14
13
|
const get_transport_max_size_1 = require("./get_transport_max_size");
|
|
14
|
+
const read_max_byte_string_length_1 = require("./read_max_byte_string_length");
|
|
15
15
|
const debugLog = (0, node_opcua_debug_1.make_debugLog)("FileType");
|
|
16
16
|
// const errorLog = make_errorLog("FileType");
|
|
17
17
|
// const warningLog = make_warningLog("FileType");
|
|
@@ -31,7 +31,7 @@ async function writeOPCUAFile(clientFile, filePath, { chunkSize }) {
|
|
|
31
31
|
await clientFile.setPosition(0);
|
|
32
32
|
try {
|
|
33
33
|
const outStream = new node_stream_1.Writable({
|
|
34
|
-
write(chunk,
|
|
34
|
+
write(chunk, _encoding, callback) {
|
|
35
35
|
doDebug && debugLog("writing chunk", chunk.length);
|
|
36
36
|
clientFile
|
|
37
37
|
.write(chunk)
|
|
@@ -43,7 +43,8 @@ async function writeOPCUAFile(clientFile, filePath, { chunkSize }) {
|
|
|
43
43
|
await (0, promises_1.pipeline)(readStream, outStream);
|
|
44
44
|
}
|
|
45
45
|
catch (e) {
|
|
46
|
-
|
|
46
|
+
// c8 ignore next
|
|
47
|
+
doDebug && debugLog(e.message);
|
|
47
48
|
throw e;
|
|
48
49
|
}
|
|
49
50
|
finally {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"write_file.js","sourceRoot":"","sources":["../../source/client/write_file.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"write_file.js","sourceRoot":"","sources":["../../source/client/write_file.ts"],"names":[],"mappings":";;;;;AAeA,wCAmCC;AAlDD,sDAAyB;AACzB,6CAAuC;AACvC,mDAAgD;AAEhD,uEAAwD;AACxD,uDAAiE;AACjE,+CAA+D;AAC/D,qEAA0G;AAC1G,+EAAwE;AAExE,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,8CAA8C;AAC9C,kDAAkD;AAClD,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAEpC,KAAK,UAAU,cAAc,CAAC,UAAuB,EAAE,QAAgB,EAAE,EAAE,SAAS,EAA0B;IACjH,MAAM,cAAc,GAAG,IAAA,mDAA0B,EAAC,UAAU,CAAC,OAAwC,CAAC,CAAC;IAEvG,SAAS,GAAG,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,IAAA,qDAAuB,EAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpG,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,uCAAY,CAAC,mBAAmB,CAAC,CAAC;IAClE,IAAI,cAAc,GAAG,GAAG,EAAE,CAAC;QACvB,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,cAAc,GAAG,IAAI,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,CAAC,iBAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,KAAK,CAAC,QAAQ,QAAQ,iBAAiB,CAAC,CAAC;IACvD,CAAC;IACD,MAAM,UAAU,GAAG,iBAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC;IAC/E,MAAM,UAAU,CAAC,IAAI,CAAC,0BAAY,CAAC,kBAAkB,CAAC,CAAC;IACvD,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,IAAI,CAAC;QACD,MAAM,SAAS,GAAG,IAAI,sBAAQ,CAAC;YAC3B,KAAK,CAAC,KAAK,EAAE,SAAS,EAAE,QAAQ;gBAC5B,OAAO,IAAI,QAAQ,CAAC,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBACnD,UAAU;qBACL,KAAK,CAAC,KAAK,CAAC;qBACZ,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;qBACtB,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;YACvC,CAAC;SACJ,CAAC,CAAC;QACH,6CAA6C;QAC7C,MAAM,IAAA,mBAAQ,EAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,iBAAiB;QACjB,OAAO,IAAI,QAAQ,CAAE,CAAW,CAAC,OAAO,CAAC,CAAC;QAC1C,MAAM,CAAC,CAAC;IACZ,CAAC;YAAS,CAAC;QACP,OAAO,IAAI,QAAQ,CAAC,wBAAwB,CAAC,CAAC;QAC9C,MAAM,UAAU,CAAC,KAAK,EAAE,CAAC;IAC7B,CAAC;AACL,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface ReadStreamOptions {
|
|
3
|
-
}
|
|
1
|
+
import type { NoParamCallback, OpenMode, PathLike, Stats, WriteFileOptions } from "node:fs";
|
|
4
2
|
export interface AbstractFs {
|
|
5
3
|
stat(path: PathLike, callback: (err: NodeJS.ErrnoException | null, stats: Stats) => void): void;
|
|
6
4
|
statSync(path: PathLike): Stats;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -18,6 +18,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
18
18
|
* @module node-opcua-file-transfer
|
|
19
19
|
*/
|
|
20
20
|
__exportStar(require("./client"), exports);
|
|
21
|
-
__exportStar(require("./server/file_type_helpers"), exports);
|
|
22
21
|
__exportStar(require("./common/abstract_fs"), exports);
|
|
22
|
+
__exportStar(require("./server/file_type_helpers"), exports);
|
|
23
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,2CAAyB;AACzB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,2CAAyB;AACzB,uDAAqC;AACrC,6DAA2C"}
|
package/dist/open_mode.js
CHANGED
|
@@ -17,13 +17,16 @@ var OpenFileMode;
|
|
|
17
17
|
* Read bit 0 The file is opened for reading. If this bit is not
|
|
18
18
|
* set the Read Method cannot be executed.
|
|
19
19
|
*/
|
|
20
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits; must stay a real numeric enum for the OpenFileMode[mode] reverse lookup used in error messages
|
|
20
21
|
OpenFileMode[OpenFileMode["Read"] = 1] = "Read";
|
|
21
22
|
/**
|
|
22
23
|
* Write bit 1 The file is opened for writing. If this bit is not
|
|
23
24
|
* set the Write Method cannot be executed.
|
|
24
25
|
*
|
|
25
26
|
*/
|
|
27
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits, see above
|
|
26
28
|
OpenFileMode[OpenFileMode["Write"] = 2] = "Write";
|
|
29
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits, see above
|
|
27
30
|
OpenFileMode[OpenFileMode["ReadWrite"] = 3] = "ReadWrite";
|
|
28
31
|
/**
|
|
29
32
|
*
|
|
@@ -32,14 +35,18 @@ var OpenFileMode;
|
|
|
32
35
|
* (Write bit is set). The existing content of the file is
|
|
33
36
|
* erased and an empty file is provided.
|
|
34
37
|
*/
|
|
38
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits, see above
|
|
35
39
|
OpenFileMode[OpenFileMode["WriteEraseExisting"] = 6] = "WriteEraseExisting";
|
|
40
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits, see above
|
|
36
41
|
OpenFileMode[OpenFileMode["ReadWriteEraseExisting"] = 7] = "ReadWriteEraseExisting";
|
|
37
42
|
/**
|
|
38
43
|
* Append 3 When the Append bit is set the file is opened at end
|
|
39
44
|
* of the file, otherwise at begin of the file.
|
|
40
45
|
* The SetPosition Method can be used to change the position.
|
|
41
46
|
*/
|
|
47
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits, see above
|
|
42
48
|
OpenFileMode[OpenFileMode["WriteAppend"] = 10] = "WriteAppend";
|
|
49
|
+
// biome-ignore lint/style/useLiteralEnumMembers: composed from OpenFileModeMask bits, see above
|
|
43
50
|
OpenFileMode[OpenFileMode["ReadWriteAppend"] = 11] = "ReadWriteAppend";
|
|
44
51
|
})(OpenFileMode || (exports.OpenFileMode = OpenFileMode = {}));
|
|
45
52
|
//# sourceMappingURL=open_mode.js.map
|
package/dist/open_mode.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"open_mode.js","sourceRoot":"","sources":["../source/open_mode.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,6DAAc,CAAA;IACd,+DAAe,CAAA;IACf,+EAAuB,CAAA;IACvB,iEAAgB,CAAA;AACpB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAED,IAAY,
|
|
1
|
+
{"version":3,"file":"open_mode.js","sourceRoot":"","sources":["../source/open_mode.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,gBAKX;AALD,WAAY,gBAAgB;IACxB,6DAAc,CAAA;IACd,+DAAe,CAAA;IACf,+EAAuB,CAAA;IACvB,iEAAgB,CAAA;AACpB,CAAC,EALW,gBAAgB,gCAAhB,gBAAgB,QAK3B;AAED,IAAY,YAqCX;AArCD,WAAY,YAAY;IACpB;;;OAGG;IACH,qLAAqL;IACrL,+CAA+B,CAAA;IAC/B;;;;OAIG;IACH,gGAAgG;IAChG,iDAAiC,CAAA;IACjC,gGAAgG;IAChG,yDAAgE,CAAA;IAEhE;;;;;;OAMG;IACH,gGAAgG;IAChG,2EAAkF,CAAA;IAClF,gGAAgG;IAChG,mFAAiH,CAAA;IACjH;;;;OAIG;IACH,gGAAgG;IAChG,8DAAoE,CAAA;IACpE,gGAAgG;IAChG,sEAAmG,CAAA;AACvG,CAAC,EArCW,YAAY,4BAAZ,YAAY,QAqCvB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module node-opcua-file-transfer
|
|
3
3
|
*/
|
|
4
|
-
import { UAFile, UAFile_Base, UAObjectType } from "node-opcua-address-space";
|
|
5
|
-
import { NodeIdLike } from "node-opcua-nodeid";
|
|
6
|
-
import { AbstractFs } from "../common/abstract_fs";
|
|
4
|
+
import type { UAFile, UAFile_Base, UAObjectType } from "node-opcua-address-space";
|
|
5
|
+
import { type NodeIdLike } from "node-opcua-nodeid";
|
|
6
|
+
import type { AbstractFs } from "../common/abstract_fs";
|
|
7
7
|
/**
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
@@ -10,16 +10,16 @@ exports.defaultMaxSize = exports.FileTypeData = void 0;
|
|
|
10
10
|
exports.writeFile = writeFile;
|
|
11
11
|
exports.getFileData = getFileData;
|
|
12
12
|
exports.installFileType = installFileType;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const node_util_1 = require("node:util");
|
|
16
15
|
const node_opcua_address_space_base_1 = require("node-opcua-address-space-base");
|
|
16
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
17
17
|
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
|
|
18
|
+
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
18
19
|
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
19
20
|
const node_opcua_nodeid_1 = require("node-opcua-nodeid");
|
|
20
21
|
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
21
22
|
const node_opcua_variant_1 = require("node-opcua-variant");
|
|
22
|
-
const node_opcua_data_value_1 = require("node-opcua-data-value");
|
|
23
23
|
const open_mode_1 = require("../open_mode");
|
|
24
24
|
const debugLog = (0, node_opcua_debug_1.make_debugLog)("FileType");
|
|
25
25
|
const errorLog = (0, node_opcua_debug_1.make_errorLog)("FileType");
|
|
@@ -42,10 +42,10 @@ class FileTypeData {
|
|
|
42
42
|
refreshFileContentFunc;
|
|
43
43
|
constructor(options, file) {
|
|
44
44
|
this.file = file;
|
|
45
|
-
this._fs = options.fileSystem ||
|
|
45
|
+
this._fs = options.fileSystem || node_fs_1.default;
|
|
46
46
|
this.refreshFileContentFunc = options.refreshFileContentFunc;
|
|
47
47
|
this.filename = options.filename;
|
|
48
|
-
this.maxSize = options.maxSize;
|
|
48
|
+
this.maxSize = options.maxSize ?? 0;
|
|
49
49
|
this.mimeType = options.mimeType || "";
|
|
50
50
|
this.maxChunkSizeBytes = options.maxChunkSize || FileTypeData.maxChunkSize;
|
|
51
51
|
// openCount indicates the number of currently valid file handles on the file.
|
|
@@ -68,14 +68,14 @@ class FileTypeData {
|
|
|
68
68
|
data.fileSize = size;
|
|
69
69
|
return new node_opcua_data_value_1.DataValue({
|
|
70
70
|
sourceTimestamp: timestamp,
|
|
71
|
-
serverTimestamp:
|
|
71
|
+
serverTimestamp: new Date(),
|
|
72
72
|
value: new node_opcua_variant_1.Variant({ dataType: node_opcua_variant_1.DataType.UInt64, value: data._fileSize }),
|
|
73
73
|
statusCode: node_opcua_status_code_1.StatusCodes.Good
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
|
-
catch (
|
|
76
|
+
catch (_err) {
|
|
77
77
|
return new node_opcua_data_value_1.DataValue({
|
|
78
|
-
serverTimestamp:
|
|
78
|
+
serverTimestamp: new Date(),
|
|
79
79
|
statusCode: node_opcua_status_code_1.StatusCodes.BadDataUnavailable
|
|
80
80
|
});
|
|
81
81
|
}
|
|
@@ -113,13 +113,14 @@ class FileTypeData {
|
|
|
113
113
|
self._fileSize = 0;
|
|
114
114
|
return;
|
|
115
115
|
}
|
|
116
|
-
const stat = await (0,
|
|
116
|
+
const stat = await (0, node_util_1.promisify)(abstractFs.stat)(self.filename);
|
|
117
117
|
self._fileSize = stat.size;
|
|
118
|
-
|
|
118
|
+
// c8 ignore next
|
|
119
|
+
doDebug && debugLog("original file size ", self.filename, " size = ", self._fileSize);
|
|
119
120
|
}
|
|
120
121
|
catch (err) {
|
|
121
122
|
self._fileSize = 0;
|
|
122
|
-
if (
|
|
123
|
+
if (node_util_1.types.isNativeError(err)) {
|
|
123
124
|
warningLog("Cannot access file ", self.filename, err.message);
|
|
124
125
|
}
|
|
125
126
|
}
|
|
@@ -165,7 +166,7 @@ function getFileData(opcuaFile2) {
|
|
|
165
166
|
function getFileDataFromContext(context) {
|
|
166
167
|
return getFileData(context.object);
|
|
167
168
|
}
|
|
168
|
-
function _prepare(addressSpace
|
|
169
|
+
function _prepare(addressSpace) {
|
|
169
170
|
const _context = addressSpace;
|
|
170
171
|
_context.$$currentFileHandle = _context.$$currentFileHandle ? _context.$$currentFileHandle : 41;
|
|
171
172
|
_context.$$files = _context.$$files || {};
|
|
@@ -175,11 +176,11 @@ function _getSessionId(context) {
|
|
|
175
176
|
if (!context.session) {
|
|
176
177
|
return new node_opcua_nodeid_1.NodeId();
|
|
177
178
|
}
|
|
178
|
-
(0, node_opcua_assert_1.assert)(context.session
|
|
179
|
+
(0, node_opcua_assert_1.assert)(context.session?.getSessionId);
|
|
179
180
|
return context.session?.getSessionId() || new node_opcua_nodeid_1.NodeId();
|
|
180
181
|
}
|
|
181
182
|
function _addFile(addressSpace, context, openMode) {
|
|
182
|
-
const _context = _prepare(addressSpace
|
|
183
|
+
const _context = _prepare(addressSpace);
|
|
183
184
|
_context.$$currentFileHandle++;
|
|
184
185
|
const fileHandle = _context.$$currentFileHandle;
|
|
185
186
|
const sessionId = _getSessionId(context);
|
|
@@ -195,7 +196,7 @@ function _addFile(addressSpace, context, openMode) {
|
|
|
195
196
|
return fileHandle;
|
|
196
197
|
}
|
|
197
198
|
function _getFileInfo(addressSpace, context, fileHandle) {
|
|
198
|
-
const _context = _prepare(addressSpace
|
|
199
|
+
const _context = _prepare(addressSpace);
|
|
199
200
|
const _fileInfo = _context.$$files[fileHandle];
|
|
200
201
|
const sessionId = _getSessionId(context);
|
|
201
202
|
if (!_fileInfo || !(0, node_opcua_nodeid_1.sameNodeId)(_fileInfo.sessionId, sessionId)) {
|
|
@@ -204,8 +205,8 @@ function _getFileInfo(addressSpace, context, fileHandle) {
|
|
|
204
205
|
}
|
|
205
206
|
return _fileInfo;
|
|
206
207
|
}
|
|
207
|
-
function _close(addressSpace,
|
|
208
|
-
const _context = _prepare(addressSpace
|
|
208
|
+
function _close(addressSpace, fileData) {
|
|
209
|
+
const _context = _prepare(addressSpace);
|
|
209
210
|
delete _context.$$files[fileData.handle];
|
|
210
211
|
}
|
|
211
212
|
function toNodeJSMode(opcuaMode) {
|
|
@@ -278,7 +279,7 @@ async function _openFile(inputArguments, context) {
|
|
|
278
279
|
// see https://nodejs.org/api/fs.html#fs_file_system_flags
|
|
279
280
|
const flags = toNodeJSMode(mode);
|
|
280
281
|
if (flags === "?") {
|
|
281
|
-
errorLog(
|
|
282
|
+
errorLog(`Invalid mode ${open_mode_1.OpenFileMode[mode]} (${mode})`);
|
|
282
283
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument };
|
|
283
284
|
}
|
|
284
285
|
/**
|
|
@@ -302,12 +303,11 @@ async function _openFile(inputArguments, context) {
|
|
|
302
303
|
}
|
|
303
304
|
const abstractFs = _getFileSystem(context);
|
|
304
305
|
try {
|
|
305
|
-
_fileInfo.fd = await (0,
|
|
306
|
+
_fileInfo.fd = await (0, node_util_1.promisify)(abstractFs.open)(filename, flags);
|
|
306
307
|
// update position
|
|
307
308
|
_fileInfo.position = [0, 0];
|
|
308
|
-
const fileLength = (await (0,
|
|
309
|
+
const fileLength = (await (0, node_util_1.promisify)(abstractFs.stat)(filename)).size;
|
|
309
310
|
_fileInfo.size = fileLength;
|
|
310
|
-
// tslint:disable-next-line:no-bitwise
|
|
311
311
|
if ((mode & open_mode_1.OpenFileModeMask.AppendBit) === open_mode_1.OpenFileModeMask.AppendBit) {
|
|
312
312
|
_fileInfo.position[1] = fileLength;
|
|
313
313
|
}
|
|
@@ -317,13 +317,14 @@ async function _openFile(inputArguments, context) {
|
|
|
317
317
|
fileData.openCount += 1;
|
|
318
318
|
}
|
|
319
319
|
catch (err) {
|
|
320
|
-
if (
|
|
320
|
+
if (node_util_1.types.isNativeError(err)) {
|
|
321
321
|
errorLog(err.message);
|
|
322
322
|
errorLog(err.stack);
|
|
323
323
|
}
|
|
324
324
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadUnexpectedError };
|
|
325
325
|
}
|
|
326
|
-
|
|
326
|
+
// c8 ignore next
|
|
327
|
+
doDebug && debugLog("Opening file handle ", fileHandle, "filename: ", fileData.filename, "openCount: ", fileData.openCount);
|
|
327
328
|
const callMethodResult = {
|
|
328
329
|
outputArguments: [
|
|
329
330
|
{
|
|
@@ -356,9 +357,10 @@ async function _closeFile(inputArguments, context) {
|
|
|
356
357
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument };
|
|
357
358
|
}
|
|
358
359
|
const fileData = getFileDataFromContext(context);
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
360
|
+
// c8 ignore next
|
|
361
|
+
doDebug && debugLog("Closing file handle ", fileHandle, "filename: ", fileData.filename, "openCount: ", fileData.openCount);
|
|
362
|
+
await (0, node_util_1.promisify)(abstractFs.close)(_fileInfo.fd);
|
|
363
|
+
_close(addressSpace, _fileInfo);
|
|
362
364
|
fileData.openCount -= 1;
|
|
363
365
|
return {
|
|
364
366
|
statusCode: node_opcua_status_code_1.StatusCodes.Good
|
|
@@ -390,7 +392,6 @@ async function _readFile(inputArguments, context) {
|
|
|
390
392
|
if (!_fileInfo) {
|
|
391
393
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidState };
|
|
392
394
|
}
|
|
393
|
-
// tslint:disable-next-line:no-bitwise
|
|
394
395
|
if ((_fileInfo.openMode & open_mode_1.OpenFileModeMask.ReadBit) === 0x0) {
|
|
395
396
|
// open mode did not specify Read Flag
|
|
396
397
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidState };
|
|
@@ -420,7 +421,7 @@ async function _readFile(inputArguments, context) {
|
|
|
420
421
|
let ret = { bytesRead: 0 };
|
|
421
422
|
try {
|
|
422
423
|
// note: we do not util.promise here as it has a wierd behavior...
|
|
423
|
-
ret = await new Promise((resolve, reject) => abstractFs.read(_fileInfo.fd, data, 0, length, _fileInfo.position[1], (err, bytesRead,
|
|
424
|
+
ret = await new Promise((resolve, reject) => abstractFs.read(_fileInfo.fd, data, 0, length, _fileInfo.position[1], (err, bytesRead, _buff) => {
|
|
424
425
|
if (err) {
|
|
425
426
|
return reject(err);
|
|
426
427
|
}
|
|
@@ -429,7 +430,7 @@ async function _readFile(inputArguments, context) {
|
|
|
429
430
|
_fileInfo.position[1] += ret.bytesRead;
|
|
430
431
|
}
|
|
431
432
|
catch (err) {
|
|
432
|
-
if (
|
|
433
|
+
if (node_util_1.types.isNativeError(err)) {
|
|
433
434
|
errorLog("Read error : ", err.message);
|
|
434
435
|
}
|
|
435
436
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadUnexpectedError };
|
|
@@ -449,7 +450,6 @@ async function _writeFile(inputArguments, context) {
|
|
|
449
450
|
if (!_fileInfo) {
|
|
450
451
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidArgument };
|
|
451
452
|
}
|
|
452
|
-
// tslint:disable-next-line:no-bitwise
|
|
453
453
|
if ((_fileInfo.openMode & open_mode_1.OpenFileModeMask.WriteBit) === 0x00) {
|
|
454
454
|
// File has not been open with write mode
|
|
455
455
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadInvalidState };
|
|
@@ -471,12 +471,14 @@ async function _writeFile(inputArguments, context) {
|
|
|
471
471
|
_fileInfo.position[1] += ret.bytesWritten;
|
|
472
472
|
_fileInfo.size = Math.max(_fileInfo.size, _fileInfo.position[1]);
|
|
473
473
|
const fileData = getFileDataFromContext(context);
|
|
474
|
-
|
|
474
|
+
// c8 ignore next
|
|
475
|
+
doDebug && debugLog(fileData.fileSize);
|
|
475
476
|
fileData.fileSize = Math.max(fileData.fileSize, _fileInfo.position[1]);
|
|
476
|
-
|
|
477
|
+
// c8 ignore next
|
|
478
|
+
doDebug && debugLog(fileData.fileSize);
|
|
477
479
|
}
|
|
478
480
|
catch (err) {
|
|
479
|
-
if (
|
|
481
|
+
if (node_util_1.types.isNativeError(err)) {
|
|
480
482
|
errorLog("Write error : ", err.message);
|
|
481
483
|
}
|
|
482
484
|
return { statusCode: node_opcua_status_code_1.StatusCodes.BadUnexpectedError };
|