add proper version

This commit is contained in:
Damien Elmes 2020-02-04 20:07:28 +10:00
parent de27cf2a63
commit 0f7fc1e960
3 changed files with 14 additions and 4 deletions

View File

@ -5,6 +5,10 @@
mod backend_proto;
pub fn version() -> &'static str {
include_str!("../../meta/version").trim()
}
pub mod backend;
pub mod cloze;
pub mod err;

View File

@ -7,6 +7,7 @@ use crate::media::files::{
add_file_from_ankiweb, data_for_file, normalize_filename, remove_files, AddedFile,
};
use crate::media::{register_changes, MediaManager};
use crate::version;
use bytes::Bytes;
use log::debug;
use reqwest;
@ -19,8 +20,6 @@ use std::io::{Read, Write};
use std::path::Path;
use std::{io, time};
// fixme: version string
static SYNC_MAX_FILES: usize = 25;
static SYNC_MAX_BYTES: usize = (2.5 * 1024.0 * 1024.0) as usize;
@ -71,12 +70,12 @@ where
}
async fn sync_begin(&self, hkey: &str) -> Result<(String, i32)> {
let url = format!("{}/begin", self.endpoint);
let url = format!("{}begin", self.endpoint);
let resp = self
.client
.get(&url)
.query(&[("k", hkey), ("v", "ankidesktop,2.1.19,mac")])
.query(&[("k", hkey), ("v", &version_string())])
.send()
.await?
.error_for_status()?;
@ -602,6 +601,10 @@ fn zip_files(media_folder: &Path, files: &[MediaEntry]) -> Result<Vec<u8>> {
Ok(w.into_inner())
}
fn version_string() -> String {
format!("anki,{},{}", version(), std::env::consts::OS)
}
#[derive(Serialize)]
struct FinalizeRequest {
local: u32,

View File

@ -1,3 +1,6 @@
// Copyright: Ankitects Pty Ltd and contributors
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
use anki::backend::{init_backend, Backend as RustBackend};
use log::error;
use pyo3::prelude::*;