Skip to content

Commit 40ee527

Browse files
David BetzDavid Betz
David Betz
authored and
David Betz
committed
Don't try reading a file as an image if we're going to write it to the SD card.
1 parent 11e229d commit 40ee527

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

src/main.cpp

+14-16
Original file line numberDiff line numberDiff line change
@@ -276,27 +276,25 @@ int main(int argc, char *argv[])
276276
}
277277

278278
/* before we do anything else, make sure we can read the Propeller image file */
279-
if (file) {
279+
if (file && !writeFile) {
280280
nmessage(INFO_OPENING_FILE, file);
281281
if (!(image = Loader::readFile(file, &imageSize))) {
282282
nmessage(ERROR_CANT_OPEN_FILE, file);
283283
return 1;
284284
}
285-
if (!writeFile) {
286-
switch (PropImage::validate(image, imageSize)) {
287-
case PropImage::SUCCESS:
288-
// success
289-
break;
290-
case PropImage::IMAGE_TRUNCATED:
291-
nmessage(ERROR_FILE_TRUNCATED);
292-
return 1;
293-
case PropImage::IMAGE_CORRUPTED:
294-
nmessage(ERROR_FILE_CORRUPTED);
295-
return 1;
296-
default:
297-
nmessage(ERROR_INTERNAL_CODE_ERROR);
298-
return 1;
299-
}
285+
switch (PropImage::validate(image, imageSize)) {
286+
case PropImage::SUCCESS:
287+
// success
288+
break;
289+
case PropImage::IMAGE_TRUNCATED:
290+
nmessage(ERROR_FILE_TRUNCATED);
291+
return 1;
292+
case PropImage::IMAGE_CORRUPTED:
293+
nmessage(ERROR_FILE_CORRUPTED);
294+
return 1;
295+
default:
296+
nmessage(ERROR_INTERNAL_CODE_ERROR);
297+
return 1;
300298
}
301299
}
302300

0 commit comments

Comments
 (0)