urlfetcher: Force a flush after writing to a file

While downloading really small files, on some file systems, the files
may not be flushed on time for whatever reason they've been downloaded.

This issue was noticed after trying to perform unattended installations
and noticing that some files, particularly really small ones, where just
empty.

While the original issue would be fixed by doing the flush on
_HTTPURLFetcher::_write(), let's also force it on _URLFetcher::_write()
to do the same.

Reviewed-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
This commit is contained in:
Fabiano Fidêncio 2019-08-05 13:47:25 +02:00 committed by Cole Robinson
parent 7f8648c53d
commit 5324582747

View File

@ -156,6 +156,7 @@ class _URLFetcher(object):
fileobj.write(buff)
total += len(buff)
self.meter.update(total)
fileobj.flush()
return total
def _grabber(self, url):
@ -291,6 +292,7 @@ class _HTTPURLFetcher(_URLFetcher):
fileobj.write(data)
total += len(data)
self.meter.update(total)
fileobj.flush()
return total