@@ -74,16 +74,18 @@ pub fn update(version: &str) -> std::io::Result<()>{
74
74
let _release_linux = format ! ( "https://github.com/zhangzijie-pro/Tiks/releases/download/{}/tiks" , version) ;
75
75
let _release_window = format ! ( "https://github.com/zhangzijie-pro/Tiks/releases/download/{}/tiks.exe" , version) ;
76
76
77
- #[ cfg( target_os="linux" ) ]
78
- let app_linux = _get_linux_dir ( ) ;
79
- task:: block_on ( async {
80
- update_to ( & _release_linux, app_linux) ;
81
- } ) ;
82
- #[ cfg( target_os="windows" ) ] {
83
- let app_window = _get_window_dir ( ) ;
84
- task:: block_on ( async {
85
- update_to ( & _release_window, app_window) ;
86
- } ) ;
77
+ if cfg ! ( target_os = "linux" ) | cfg ! ( target_os="mac" ) {
78
+ let app_linux = get_linux_dir ( ) ;
79
+ task:: block_on ( async {
80
+ update_to ( & _release_linux, app_linux) . await ;
81
+ } ) ;
82
+ }
83
+
84
+ if cfg ! ( target_os="windows" ) {
85
+ let app_window = get_window_dir ( ) ;
86
+ task:: block_on ( async {
87
+ update_to ( & _release_window, app_window) . await ;
88
+ } ) ;
87
89
}
88
90
89
91
Ok ( ( ) )
@@ -93,19 +95,24 @@ pub fn update(version: &str) -> std::io::Result<()>{
93
95
pub async fn update_last ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
94
96
let client = Client :: new ( ) ;
95
97
96
- #[ cfg( target_os="linux" ) ]
97
- let response = client. get ( _GITHUB_RELEASE_LINUX) . send ( ) . await . expect ( "Error: update error" ) ;
98
- let app = _get_linux_dir ( ) ;
99
- let mut file = File :: create ( app) . expect ( "Can't create file : tiks" ) ;
100
-
101
- #[ cfg( target_os="windows" ) ] {
102
- let response = client. get ( _GITHUB_RELEASE_WINDOW) . send ( ) . await . expect ( "Error: update error" ) ;
103
- let app = _get_window_dir ( ) ;
104
- let mut file = File :: create ( app) . expect ( "Can't create file : tiks" ) ;
98
+ if cfg ! ( target_os = "linux" ) | cfg ! ( target_os="mac" ) {
99
+ let response = client. get ( _GITHUB_RELEASE_LINUX) . send ( ) . await . expect ( "Error: update error" ) ;
100
+ let app = get_linux_dir ( ) ;
101
+ let mut file = File :: create ( app) . expect ( "Can't create file : tiks" ) ;
102
+
103
+ let byte = response. bytes ( ) . await . unwrap ( ) ;
104
+ let _ = file. write_all ( & byte) ;
105
+ }
106
+
107
+ if cfg ! ( target_os="windows" ) {
108
+ let response = client. get ( _GITHUB_RELEASE_WINDOW) . send ( ) . await . expect ( "Error: update error" ) ;
109
+ let app = get_window_dir ( ) ;
110
+ let mut file = File :: create ( app) . expect ( "Can't create file : tiks" ) ;
111
+
112
+ let byte = response. bytes ( ) . await . unwrap ( ) ;
113
+ let _ = file. write_all ( & byte) ;
105
114
}
106
115
107
- let byte = response. bytes ( ) . await . unwrap ( ) ;
108
- let _ = file. write_all ( & byte) ;
109
116
Ok ( ( ) )
110
117
}
111
118
@@ -123,15 +130,15 @@ async fn update_to(url: &str,filename: PathBuf) -> Result<(), Box<dyn std::error
123
130
}
124
131
125
132
126
- fn _get_window_dir ( ) -> PathBuf {
133
+ fn get_window_dir ( ) -> PathBuf {
127
134
let home = dirs:: home_dir ( ) . unwrap ( ) ;
128
135
let app_dir = home. join ( ".Tiks" ) ;
129
136
let app_window = app_dir. join ( "bin" ) . join ( "tiks.exe" ) ;
130
137
131
138
app_window
132
139
}
133
140
134
- fn _get_linux_dir ( ) -> PathBuf {
141
+ fn get_linux_dir ( ) -> PathBuf {
135
142
let home = dirs:: home_dir ( ) . unwrap ( ) ;
136
143
let app_dir = home. join ( ".Tiks" ) ;
137
144
let app_linux = app_dir. join ( "bin" ) . join ( "tiks" ) ;
0 commit comments