Skip to content

Commit 51b1be6

Browse files
committed
Fix absurd upload corner case
1 parent 6cf5613 commit 51b1be6

File tree

3 files changed

+36
-43
lines changed

3 files changed

+36
-43
lines changed

cli/upload/upload.go

+13-20
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import (
2828
"github.com/arduino/arduino-cli/commands/upload"
2929
"github.com/arduino/arduino-cli/i18n"
3030
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
31-
"github.com/arduino/go-paths-helper"
3231
"github.com/spf13/cobra"
3332
)
3433

@@ -82,28 +81,22 @@ func run(command *cobra.Command, args []string) {
8281
if len(args) > 0 {
8382
path = args[0]
8483
}
85-
var sketchPath *paths.Path
86-
var sk *sketch.Sketch = nil
87-
// If the user explicitly specified a directory that contains binaries to upload
88-
// use those, we don't really need a valid Sketch to upload in this case
89-
if importDir == "" && importFile == "" {
90-
sketchPath = arguments.InitSketchPath(path)
91-
92-
// .pde files are still supported but deprecated, this warning urges the user to rename them
93-
if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 {
94-
feedback.Error(tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:"))
95-
for _, f := range files {
96-
feedback.Error(f)
97-
}
98-
}
84+
sketchPath := arguments.InitSketchPath(path)
9985

100-
var err error
101-
sk, err = sketch.New(sketchPath)
102-
if err != nil {
103-
feedback.Errorf(tr("Error during Upload: %v"), err)
104-
os.Exit(errorcodes.ErrGeneric)
86+
// .pde files are still supported but deprecated, this warning urges the user to rename them
87+
if files := sketch.CheckForPdeFiles(sketchPath); len(files) > 0 && importDir == "" && importFile == "" {
88+
feedback.Error(tr("Sketches with .pde extension are deprecated, please rename the following files to .ino:"))
89+
for _, f := range files {
90+
feedback.Error(f)
10591
}
10692
}
93+
94+
sk, err := sketch.New(sketchPath)
95+
if err != nil && importDir == "" && importFile == "" {
96+
feedback.Errorf(tr("Error during Upload: %v"), err)
97+
os.Exit(errorcodes.ErrGeneric)
98+
}
99+
107100
discoveryPort, err := port.GetPort(instance, sk)
108101
if err != nil {
109102
feedback.Errorf(tr("Error during Upload: %v"), err)

i18n/data/en.po

+16-16
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ msgstr "Available"
232232
msgid "Available Commands:"
233233
msgstr "Available Commands:"
234234

235-
#: cli/upload/upload.go:62
235+
#: cli/upload/upload.go:61
236236
msgid "Binary file to upload."
237237
msgstr "Binary file to upload."
238238

@@ -552,7 +552,7 @@ msgstr "Detects and displays a list of boards connected to the current computer.
552552
msgid "Directory containing binaries for debug."
553553
msgstr "Directory containing binaries for debug."
554554

555-
#: cli/upload/upload.go:61
555+
#: cli/upload/upload.go:60
556556
msgid "Directory containing binaries to upload."
557557
msgstr "Directory containing binaries to upload."
558558

@@ -573,7 +573,7 @@ msgid "Do not install dependencies."
573573
msgstr "Do not install dependencies."
574574

575575
#: cli/burnbootloader/burnbootloader.go:58
576-
#: cli/upload/upload.go:66
576+
#: cli/upload/upload.go:65
577577
msgid "Do not perform the actual upload, just log out actions"
578578
msgstr "Do not perform the actual upload, just log out actions"
579579

@@ -725,10 +725,10 @@ msgstr "Error during JSON encoding of the output: %v"
725725
#: cli/compile/compile.go:202
726726
#: cli/compile/compile.go:212
727727
#: cli/compile/compile.go:244
728-
#: cli/upload/upload.go:103
729-
#: cli/upload/upload.go:109
730-
#: cli/upload/upload.go:125
731-
#: cli/upload/upload.go:152
728+
#: cli/upload/upload.go:96
729+
#: cli/upload/upload.go:102
730+
#: cli/upload/upload.go:118
731+
#: cli/upload/upload.go:145
732732
msgid "Error during Upload: %v"
733733
msgstr "Error during Upload: %v"
734734

@@ -1086,7 +1086,7 @@ msgstr "Force skip of post-install scripts (if the CLI is running interactively)
10861086
#: cli/burnbootloader/burnbootloader.go:53
10871087
#: cli/compile/compile.go:85
10881088
#: cli/debug/debug.go:62
1089-
#: cli/upload/upload.go:59
1089+
#: cli/upload/upload.go:58
10901090
msgid "Fully Qualified Board Name, e.g.: arduino:avr:uno"
10911091
msgstr "Fully Qualified Board Name, e.g.: arduino:avr:uno"
10921092

@@ -1575,12 +1575,12 @@ msgid "Optional, suppresses almost every output."
15751575
msgstr "Optional, suppresses almost every output."
15761576

15771577
#: cli/compile/compile.go:98
1578-
#: cli/upload/upload.go:64
1578+
#: cli/upload/upload.go:63
15791579
msgid "Optional, turns on verbose mode."
15801580
msgstr "Optional, turns on verbose mode."
15811581

15821582
#: cli/compile/compile.go:109
1583-
#: cli/upload/upload.go:65
1583+
#: cli/upload/upload.go:64
15841584
msgid "Optional, use the specified programmer to upload."
15851585
msgstr "Optional, use the specified programmer to upload."
15861586

@@ -1947,7 +1947,7 @@ msgstr "Sketch uses {0} bytes ({2}%%) of program storage space. Maximum is {1} b
19471947

19481948
#: cli/compile/compile.go:137
19491949
#: cli/sketch/archive.go:66
1950-
#: cli/upload/upload.go:94
1950+
#: cli/upload/upload.go:88
19511951
msgid "Sketches with .pde extension are deprecated, please rename the following files to .ino:"
19521952
msgstr "Sketches with .pde extension are deprecated, please rename the following files to .ino:"
19531953

@@ -2219,11 +2219,11 @@ msgstr "Upgrades one or all installed platforms to the latest version."
22192219
msgid "Upgrading platform %[1]s with %[2]s"
22202220
msgstr "Upgrading platform %[1]s with %[2]s"
22212221

2222-
#: cli/upload/upload.go:51
2222+
#: cli/upload/upload.go:50
22232223
msgid "Upload Arduino sketches."
22242224
msgstr "Upload Arduino sketches."
22252225

2226-
#: cli/upload/upload.go:52
2226+
#: cli/upload/upload.go:51
22272227
msgid "Upload Arduino sketches. This does NOT compile the sketch prior to upload."
22282228
msgstr "Upload Arduino sketches. This does NOT compile the sketch prior to upload."
22292229

@@ -2252,7 +2252,7 @@ msgid "Upload the bootloader."
22522252
msgstr "Upload the bootloader."
22532253

22542254
#: cli/compile/compile.go:218
2255-
#: cli/upload/upload.go:131
2255+
#: cli/upload/upload.go:124
22562256
msgid "Uploading to specified board using %s protocol requires the following info:"
22572257
msgstr "Uploading to specified board using %s protocol requires the following info:"
22582258

@@ -2320,7 +2320,7 @@ msgstr "VERSION_NUMBER"
23202320

23212321
#: cli/burnbootloader/burnbootloader.go:55
23222322
#: cli/compile/compile.go:102
2323-
#: cli/upload/upload.go:63
2323+
#: cli/upload/upload.go:62
23242324
msgid "Verify uploaded binary after the upload."
23252325
msgstr "Verify uploaded binary after the upload."
23262326

@@ -2607,7 +2607,7 @@ msgstr "error processing response from server"
26072607
msgid "error querying Arduino Cloud Api"
26082608
msgstr "error querying Arduino Cloud Api"
26092609

2610-
#: cli/upload/upload.go:73
2610+
#: cli/upload/upload.go:72
26112611
msgid "error: %s and %s flags cannot be used together"
26122612
msgstr "error: %s and %s flags cannot be used together"
26132613

i18n/rice-box.go

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)