From fa239be1249ade9ba623aae657b3de273f2a46d1 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Thu, 16 Jul 2020 10:12:41 +1000 Subject: [PATCH] add platform version back into sync metadata --- qt/aqt/sync.py | 5 +++++ rslib/src/version.rs | 9 +++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/qt/aqt/sync.py b/qt/aqt/sync.py index f90ca3e21..7bbfd33e3 100644 --- a/qt/aqt/sync.py +++ b/qt/aqt/sync.py @@ -4,6 +4,7 @@ from __future__ import annotations import enum +import os from typing import Callable, Tuple import aqt @@ -18,6 +19,7 @@ from anki.rsbackend import ( SyncOutput, SyncStatus, ) +from anki.utils import platDesc from aqt.qt import ( QDialog, QDialogButtonBox, @@ -316,3 +318,6 @@ def get_id_and_pass_from_user( if not accepted: return ("", "") return (user.text().strip(), passwd.text()) + +# export platform version to syncing code +os.environ["PLATFORM"] = platDesc() diff --git a/rslib/src/version.rs b/rslib/src/version.rs index 353da6319..38a4fd3ff 100644 --- a/rslib/src/version.rs +++ b/rslib/src/version.rs @@ -2,6 +2,7 @@ // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html use lazy_static::lazy_static; +use std::env; pub fn version() -> &'static str { include_str!("../../meta/version").trim() @@ -14,10 +15,10 @@ pub fn buildhash() -> &'static str { pub(crate) fn sync_client_version() -> &'static str { lazy_static! { static ref VER: String = format!( - "anki,{} ({}),{}", - version(), - buildhash(), - std::env::consts::OS + "anki,{version} ({buildhash}),{platform}", + version = version(), + buildhash = buildhash(), + platform = env::var("PLATFORM").unwrap_or_else(|_| env::consts::OS.to_string()) ); } &VER