add platform version back into sync metadata

This commit is contained in:
Damien Elmes 2020-07-16 10:12:41 +10:00
parent 1205db6484
commit fa239be124
2 changed files with 10 additions and 4 deletions

View file

@ -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()

View file

@ -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