fix: omit port from upload request when not set

Previously, if the `port` was not set in IDE2, the compile request
object has been created with an empty port object (`{}`). From now on,
if the port is not specified, IDE2 will create a compile request with
the default `null` `port` value.

Closes #2089

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2023-06-06 13:42:19 +02:00
committed by Akos Kitta
parent 0fbd1fbe85
commit db0049d635
2 changed files with 55 additions and 10 deletions

View File

@@ -411,17 +411,21 @@ export class CoreServiceImpl extends CoreClientAware implements CoreService {
}
}
private createPort(port: Port | undefined): RpcPort {
private createPort(port: Port | undefined): RpcPort | undefined {
if (!port) {
return undefined;
}
const rpcPort = new RpcPort();
if (port) {
rpcPort.setAddress(port.address);
rpcPort.setLabel(port.addressLabel);
rpcPort.setProtocol(port.protocol);
rpcPort.setProtocolLabel(port.protocolLabel);
if (port.properties) {
for (const [key, value] of Object.entries(port.properties)) {
rpcPort.getPropertiesMap().set(key, value);
}
rpcPort.setAddress(port.address);
rpcPort.setLabel(port.addressLabel);
rpcPort.setProtocol(port.protocol);
rpcPort.setProtocolLabel(port.protocolLabel);
if (port.hardwareId !== undefined) {
rpcPort.setHardwareId(port.hardwareId);
}
if (port.properties) {
for (const [key, value] of Object.entries(port.properties)) {
rpcPort.getPropertiesMap().set(key, value);
}
}
return rpcPort;