feat: Versionsnummer auf 1.0.5 erhöht und Installationsskript aktualisiert
This commit is contained in:
19
app.py
19
app.py
@@ -18,8 +18,18 @@ from flask import Flask, jsonify, request
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
VERSION = '1.0.3'
|
||||
RAW_BASE = 'https://git.leuschner.dev/Tobias/PiCopy/raw/branch/main'
|
||||
VERSION_FILE = Path(__file__).with_name('version.txt')
|
||||
|
||||
|
||||
def load_installed_version():
|
||||
try:
|
||||
return VERSION_FILE.read_text(encoding='utf-8').strip() or '1.0.4'
|
||||
except Exception:
|
||||
return 'X.X.X'
|
||||
|
||||
|
||||
VERSION = load_installed_version()
|
||||
|
||||
BASE_DIR = Path('/opt/picopy')
|
||||
CONFIG_FILE = BASE_DIR / 'config.json'
|
||||
@@ -1091,6 +1101,8 @@ def r_update_install():
|
||||
log.info('Update wird heruntergeladen…')
|
||||
req = _urlreq.urlopen(f'{RAW_BASE}/app.py', timeout=60)
|
||||
new_code = req.read().decode()
|
||||
vreq = _urlreq.urlopen(f'{RAW_BASE}/version.txt', timeout=10)
|
||||
new_version = vreq.read().decode().strip()
|
||||
|
||||
# Syntax-Check bevor wir irgendetwas überschreiben
|
||||
compile(new_code, 'app.py', 'exec')
|
||||
@@ -1100,6 +1112,11 @@ def r_update_install():
|
||||
with open(tmp, 'rb') as fh:
|
||||
os.fsync(fh.fileno()) # Sicherstellen dass Daten auf der Platte sind
|
||||
os.replace(str(tmp), '/opt/picopy/app.py') # Atomares Umbenennen
|
||||
vtmp = Path('/opt/picopy/version.txt.tmp')
|
||||
vtmp.write_text(new_version + '\n', encoding='utf-8')
|
||||
with open(vtmp, 'rb') as fh:
|
||||
os.fsync(fh.fileno())
|
||||
os.replace(str(vtmp), '/opt/picopy/version.txt')
|
||||
log.info('Update installiert – starte Dienst neu…')
|
||||
|
||||
# Systemd startet den Dienst automatisch neu
|
||||
|
||||
Reference in New Issue
Block a user