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 from __future__ import annotations
import enum import enum
import os
from typing import Callable, Tuple from typing import Callable, Tuple
import aqt import aqt
@ -18,6 +19,7 @@ from anki.rsbackend import (
SyncOutput, SyncOutput,
SyncStatus, SyncStatus,
) )
from anki.utils import platDesc
from aqt.qt import ( from aqt.qt import (
QDialog, QDialog,
QDialogButtonBox, QDialogButtonBox,
@ -316,3 +318,6 @@ def get_id_and_pass_from_user(
if not accepted: if not accepted:
return ("", "") return ("", "")
return (user.text().strip(), passwd.text()) 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 // License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use lazy_static::lazy_static; use lazy_static::lazy_static;
use std::env;
pub fn version() -> &'static str { pub fn version() -> &'static str {
include_str!("../../meta/version").trim() include_str!("../../meta/version").trim()
@ -14,10 +15,10 @@ pub fn buildhash() -> &'static str {
pub(crate) fn sync_client_version() -> &'static str { pub(crate) fn sync_client_version() -> &'static str {
lazy_static! { lazy_static! {
static ref VER: String = format!( static ref VER: String = format!(
"anki,{} ({}),{}", "anki,{version} ({buildhash}),{platform}",
version(), version = version(),
buildhash(), buildhash = buildhash(),
std::env::consts::OS platform = env::var("PLATFORM").unwrap_or_else(|_| env::consts::OS.to_string())
); );
} }
&VER &VER