1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::version::Version;
use serde::{Deserialize, Serialize};
use std::time::UNIX_EPOCH;
#[derive(Serialize, Deserialize)]
pub struct UpdateConfig {
release_url: String,
url_type: String,
auto_update: bool,
how_often: u8,
last_check_time_stamp: u128,
current_version: Version,
}
pub fn check_update(_current_version: &Version, config: &UpdateConfig) {
if !config.auto_update {
return;
}
let time_range: u128 = (config.how_often) as u128 * 24 * 60 * 60 * 1000;
if config.last_check_time_stamp + time_range
< std::time::SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis()
{
return;
}
}
pub fn download_update() {}
pub fn install_update() {}