@@ -106,40 +106,45 @@ async fn start_hbbs_sync_async() {
106106 v[ keys:: OPTION_PRESET_DEVICE_GROUP_NAME ] = json!( device_group_name) ;
107107 }
108108 let v = v. to_string( ) ;
109- use sha2:: { Digest , Sha256 } ;
110- let mut hasher = Sha256 :: new( ) ;
111- hasher. update( url. as_bytes( ) ) ;
112- hasher. update( & v. as_bytes( ) ) ;
113- let res = hasher. finalize( ) ;
114- let hash = hbb_common:: base64:: encode( & res[ ..] ) ;
115- let old_hash = config:: Status :: get( "sysinfo_hash" ) ;
116- let ver = config:: Status :: get( "sysinfo_ver" ) ; // sysinfo_ver is the version of sysinfo on server's side
117- if hash == old_hash {
118- // When the api doesn't exist, Ok("") will be returned in test.
119- let samever = match crate :: post_request( url. replace( "heartbeat" , "sysinfo_ver" ) , "" . to_owned( ) , "" ) . await {
120- Ok ( x) => {
121- sysinfo_ver = x. clone( ) ;
122- * PRO . lock( ) . unwrap( ) = true ;
123- x == ver
124- }
125- _ => {
126- false // to make sure Pro can be assigned in below post for old
127- // hbbs pro not supporting sysinfo_ver, use false for ensuring
128- }
129- } ;
130- if samever {
131- info_uploaded = ( true , url. clone( ) , None , id. clone( ) ) ;
132- log:: info!( "sysinfo not changed, skip upload" ) ;
133- continue ;
134- }
109+ let mut hash = "" . to_owned( ) ;
110+ if crate :: is_selfhost( & url) {
111+ use sha2:: { Digest , Sha256 } ;
112+ let mut hasher = Sha256 :: new( ) ;
113+ hasher. update( url. as_bytes( ) ) ;
114+ hasher. update( & v. as_bytes( ) ) ;
115+ let res = hasher. finalize( ) ;
116+ hash = hbb_common:: base64:: encode( & res[ ..] ) ;
117+ let old_hash = config:: Status :: get( "sysinfo_hash" ) ;
118+ let ver = config:: Status :: get( "sysinfo_ver" ) ; // sysinfo_ver is the version of sysinfo on server's side
119+ if hash == old_hash {
120+ // When the api doesn't exist, Ok("") will be returned in test.
121+ let samever = match crate :: post_request( url. replace( "heartbeat" , "sysinfo_ver" ) , "" . to_owned( ) , "" ) . await {
122+ Ok ( x) => {
123+ sysinfo_ver = x. clone( ) ;
124+ * PRO . lock( ) . unwrap( ) = true ;
125+ x == ver
126+ }
127+ _ => {
128+ false // to make sure Pro can be assigned in below post for old
129+ // hbbs pro not supporting sysinfo_ver, use false for ensuring
130+ }
131+ } ;
132+ if samever {
133+ info_uploaded = ( true , url. clone( ) , None , id. clone( ) ) ;
134+ log:: info!( "sysinfo not changed, skip upload" ) ;
135+ continue ;
136+ }
137+ }
135138 }
136139 match crate :: post_request( url. replace( "heartbeat" , "sysinfo" ) , v, "" ) . await {
137140 Ok ( x) => {
138141 if x == "SYSINFO_UPDATED" {
139142 info_uploaded = ( true , url. clone( ) , None , id. clone( ) ) ;
140143 log:: info!( "sysinfo updated" ) ;
141- config:: Status :: set( "sysinfo_hash" , hash) ;
142- config:: Status :: set( "sysinfo_ver" , sysinfo_ver. clone( ) ) ;
144+ if !hash. is_empty( ) {
145+ config:: Status :: set( "sysinfo_hash" , hash) ;
146+ config:: Status :: set( "sysinfo_ver" , sysinfo_ver. clone( ) ) ;
147+ }
143148 * PRO . lock( ) . unwrap( ) = true ;
144149 } else if x == "ID_NOT_FOUND" {
145150 info_uploaded. 2 = None ; // next heartbeat will upload sysinfo again
0 commit comments