@@ -193,7 +193,7 @@ fn import_pack(pack: &String, config: &Config, opt: &Opt) -> anyhow::Result<()>
193
193
}
194
194
195
195
let mut sticker = None ;
196
- if !opt. noupload && database . is_some ( ) {
196
+ if !opt. noupload {
197
197
let mut hasher = Sha512 :: new ( ) ;
198
198
hasher. update ( & sticker_image) ;
199
199
let hash = hasher. finalize ( ) ;
@@ -208,6 +208,11 @@ fn import_pack(pack: &String, config: &Config, opt: &Opt) -> anyhow::Result<()>
208
208
) ;
209
209
210
210
let mxc_url = if let Some ( value) = database_tree. get ( & hash) {
211
+ pb. println ( format ! (
212
+ " upload sticker {:02} {} skipped; file with this hash was already uploaded" ,
213
+ i + 1 ,
214
+ tg_sticker. emoji
215
+ ) ) ;
211
216
value. clone ( )
212
217
} else {
213
218
pb. println ( format ! ( " upload sticker {:02} {}" , i + 1 , tg_sticker. emoji) ) ;
@@ -242,17 +247,16 @@ fn import_pack(pack: &String, config: &Config, opt: &Opt) -> anyhow::Result<()>
242
247
pb. finish ( ) ;
243
248
244
249
// write new entries into the database
245
- for sticker in & stickers {
246
- let db = database. as_mut ( ) . unwrap ( ) ;
247
- let hash_url = HashUrl {
248
- hash : sticker. file_hash ,
249
- url : sticker. mxc_url . clone ( )
250
- } ;
251
- writeln ! ( db, "{}" , serde_json:: to_string( & hash_url) ?) ?;
252
- // TODO write into database_tree
253
- }
254
- if database. is_some ( ) {
255
- database. unwrap ( ) . sync_data ( ) ?;
250
+ if let Some ( ref mut db) = database {
251
+ for sticker in & stickers {
252
+ let hash_url = HashUrl {
253
+ hash : sticker. file_hash ,
254
+ url : sticker. mxc_url . clone ( )
255
+ } ;
256
+ writeln ! ( db, "{}" , serde_json:: to_string( & hash_url) ?) ?;
257
+ // TODO write into database_tree
258
+ }
259
+ db. sync_data ( ) ?;
256
260
}
257
261
258
262
// save the stickerpack to file
0 commit comments