spring / upq

extracts metadata of game and map files of the spring engine
https://springfiles.springrts.com/
GNU General Public License v3.0
2 stars 5 forks source link

create tmp download directory if missing #80

Closed springraaar closed 2 years ago

springraaar commented 2 years ago

I was getting an error when trying to upload my latest map to springfiles

Traceback (most recent call last):
  File "/home/springfiles/upq/www/upload/index.py", line 99, in <module>
    msgs = SaveUploadedFile(form)
  File "/home/springfiles/upq/www/upload/index.py", line 68, in SaveUploadedFile
    total, used, free = shutil.disk_usage(tmpdir)
  File "/usr/lib/python3.7/shutil.py", line 1016, in disk_usage
    st = os.statvfs(path)
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/springfiles-upload'

This change fixes that issue.

I've modified the file on the server as well.

Another thing we noticed but I didn't change is that the check a few lines below doesn't make much sense:

    cfg = upqconfig.UpqConfig()
    for path in [cfg.paths["files"], tmpdir]:
        total, used, free = shutil.disk_usage(tmpdir)
        if free < 5 * 1024 * 1024 * 1024:
return "To few disk space availabile: %d MiB in %s" %(free / (1024 * 1024), path)

it does a "for path in ..." but then always calls the shutil.disk_usage(tmpdir) instead of shutil.disk_usage(path)

also bad english on that return string :)

abma commented 2 years ago

thanks!

https://github.com/spring/upq/commit/1fd2dec17065559f6bd57cb208768a96a61fa154

abma commented 2 years ago

i prefer the one-liner, sorry :-)