Skip to content

Commit 45a5736

Browse files
authored
Merge pull request #23 from mikerenfro/raise_runtime_if_wget_mismatch
Raise RuntimeError if wget content_length doesn't match file size
2 parents 46de5e7 + b0aa4a3 commit 45a5736

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

adafruit_pyportal.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ def wget(self, url, filename, *, chunk_size=12000):
605605
stamp = time.monotonic() - stamp
606606
print("Created file of %d bytes in %0.1f seconds" % (os.stat(filename)[6], stamp))
607607
self.neo_status((0, 0, 0))
608+
if not content_length == os.stat(filename)[6]:
609+
raise RuntimeError
608610

609611
def _connect_esp(self):
610612
self.neo_status((0, 0, 100))
@@ -731,6 +733,9 @@ def fetch(self):
731733
except OSError as error:
732734
print(error)
733735
raise OSError("""\n\nNo writable filesystem found for saving datastream. Insert an SD card or set internal filesystem to be unsafe by setting 'disable_concurrent_write_protection' in the mount options in boot.py""") # pylint: disable=line-too-long
736+
except RuntimeError as error:
737+
print(error)
738+
raise RuntimeError("wget didn't write a complete file")
734739
self.set_background(filename, self._image_position)
735740
except ValueError as error:
736741
print("Error displaying cached image. " + error.args[0])

0 commit comments

Comments
 (0)