Skip to content

Commit e47186c

Browse files
committed
workaround file check
1 parent a49e805 commit e47186c

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

internal/orchestrator/orchestrator.go

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,13 +1258,23 @@ func configureMicroInRamMode(
12581258
return err
12591259
}
12601260
defer zeros.Close()
1261-
empty, err := os.Create("/tmp/empty.elf-zsk.bin") //nolint:gosec
1262-
if err != nil {
1263-
return err
1264-
}
1265-
defer empty.Close()
1266-
if _, err := io.CopyN(empty, zeros, 50); err != nil {
1267-
return err
1261+
1262+
// FIXME: arduino-cli upload checks that a file exist but the extension is added after by the platform configuration.
1263+
// So we create two temporary files with some zeros.
1264+
for _, tmpFile := range paths.NewPathList("/tmp/empty", "/tmp/empty.elf-zsk.bin") {
1265+
if err := func(path *paths.Path) error {
1266+
empty, err := path.Create()
1267+
if err != nil {
1268+
return err
1269+
}
1270+
defer empty.Close()
1271+
if _, err := io.CopyN(empty, zeros, 50); err != nil {
1272+
return err
1273+
}
1274+
return nil
1275+
}(tmpFile); err != nil {
1276+
return fmt.Errorf("failed to write empty file %q: %w", tmpFile.String(), err)
1277+
}
12681278
}
12691279

12701280
stream, _ := commands.UploadToServerStreams(ctx, w, w)

0 commit comments

Comments
 (0)