Allow to download files of size 0
Created by: Henrik tom Wörden
In the webinterface, clicking on a link to a file with size=0, which would normally start the download, simply has no effect.
In python the following happens:
In [3]: db.File(id=6636).download()
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-baf54aec0251> in <module>
----> 1 db.File(id=6636).download()
~/CaosDB/caosdb-pylib/src/caosdb/common/models.py in download(self, target)
1622 else:
1623 file_ = NamedTemporaryFile(mode='wb', delete=False)
-> 1624 checksum = File.download_from_path(file_, self.path)
1625
1626 if self._checksum is not None and self._checksum.lower() != checksum.hexdigest().lower():
~/CaosDB/caosdb-pylib/src/caosdb/common/models.py in download_from_path(target_file, path)
1633 def download_from_path(target_file, path):
1634
-> 1635 _log_request("GET (download): " + path)
1636 response = get_connection().download_file(path)
1637
TypeError: can only concatenate str (not "NoneType") to str
Eventhough, it is pretty useless to download a file with 0B. This case should be treated properly. I think it should not behave differently than other downloads, i.e. a file with the correct name of size=0 should be created.