@@ -22,6 +22,7 @@ import (
22
22
"regexp"
23
23
"strconv"
24
24
"strings"
25
+ "sync"
25
26
26
27
"github.com/arduino/arduino-cli/arduino/cores"
27
28
"github.com/arduino/arduino-cli/arduino/discovery"
@@ -420,6 +421,9 @@ func convertLegacyPlatformToPluggableDiscovery(platform *cores.PlatformRelease)
420
421
}
421
422
}
422
423
424
+ var netPropRegexp = regexp .MustCompile (`\{upload\.network\.([^}]+)\}` )
425
+ var netPropRegexpMutex sync.Mutex
426
+
423
427
func convertLegacyNetworkPatternToPluggableDiscovery (props * properties.Map , newToolName string ) * properties.Map {
424
428
pattern , ok := props .GetOk ("upload.network_pattern" )
425
429
if ! ok {
@@ -434,11 +438,12 @@ func convertLegacyNetworkPatternToPluggableDiscovery(props *properties.Map, newT
434
438
pattern = strings .ReplaceAll (pattern , "{network.password}" , "{upload.field.password}" )
435
439
}
436
440
// Search for "{upload.network.PROPERTY}"" and convert it to "{upload.port.property.PROPERTY}"
437
- netPropRegexp := regexp . MustCompile ( `\{upload\.network\.([^}]+)\}` )
441
+ netPropRegexpMutex . Lock ( )
438
442
for netPropRegexp .MatchString (pattern ) {
439
443
netProp := netPropRegexp .FindStringSubmatch (pattern )[1 ]
440
444
pattern = strings .ReplaceAll (pattern , "{upload.network." + netProp + "}" , "{upload.port.properties." + netProp + "}" )
441
445
}
446
+ netPropRegexpMutex .Unlock ()
442
447
props .Set ("upload.pattern" , pattern )
443
448
444
449
prefix := "tools." + newToolName + "."
0 commit comments