diff --git a/backend/web/landing/www/install.py b/backend/web/landing/www/install.py index 1aae2ca..f884c30 100644 --- a/backend/web/landing/www/install.py +++ b/backend/web/landing/www/install.py @@ -10,6 +10,19 @@ import platform import sys import os +def get_executable_tmpdir(): + specified_dir = os.environ.get('TMPDIR', '') + if specified_dir: + return specified_dir + try: + if hasattr(os, 'ST_NOEXEC'): + if os.statvfs("/tmp").f_flag & os.ST_NOEXEC: + # /tmp/ is mounted as NOEXEC, so fall back to the current working directory + return os.getcwd() + except: + pass + return "/tmp/" + with urllib.request.urlopen('https://api.hishtory.dev/api/v1/download') as response: resp_body = response.read() download_options = json.loads(resp_body) @@ -31,19 +44,6 @@ else: with urllib.request.urlopen(download_url) as response: hishtory_binary = response.read() -def get_executable_tmpdir(): - specified_dir = os.environ.get('TMPDIR', '') - if specified_dir: - return specified_dir - try: - if hasattr(os, 'ST_NOEXEC'): - if os.statvfs("/tmp").f_flag & os.ST_NOEXEC: - # /tmp/ is mounted as NOEXEC, so fall back to the current working directory - return os.getcwd() - except: - pass - return "/tmp/" - tmpFilePath = os.path.join(get_executable_tmpdir(), 'hishtory-client') if os.path.exists(tmpFilePath): os.remove(tmpFilePath)