@@ -108,55 +108,68 @@ async function onLoad(plugin) {
108108 } ) ;
109109 } ) ;
110110
111- ( async ( ) => {
112- if ( nowConfig . saveDb ) {
113- output ( "Loading recalled msgs from db..." ) ;
114- var counter = 0 ;
115- for await ( const value of db . values ( ) ) {
116- counter ++ ;
117- recalledMsg . push ( value ) ;
118- if ( value . msg == null ) continue ;
119- for ( item of value . msg . elements ) {
120- if ( item . picElement != null ) {
121- item . picElement . thumbPath = new Map ( [
122- [
123- 0 ,
124- item . picElement . sourcePath
125- . replace ( "Ori" , "Thumb" )
126- . replace (
127- item . picElement . md5HexStr ,
128- item . picElement . md5HexStr + "_0"
129- )
130- ] ,
131- [
132- 198 ,
133- item . picElement . sourcePath
134- . replace ( "Ori" , "Thumb" )
135- . replace (
136- item . picElement . md5HexStr ,
137- item . picElement . md5HexStr + "_198"
138- )
139- ] ,
140- [
141- 720 ,
142- item . picElement . sourcePath
143- . replace ( "Ori" , "Thumb" )
144- . replace (
145- item . picElement . md5HexStr ,
146- item . picElement . md5HexStr + "_720"
147- )
148- ]
149- ] ) ;
150- }
111+ loadDb ( )
112+ . catch ( async ( e ) => {
113+ output (
114+ "Error while loading recalled msgs from db: " + e . toString ( ) ,
115+ ", retrying..."
116+ ) ;
117+ await loadDb ( ) ;
118+ } )
119+ . catch ( ( e ) => {
120+ output (
121+ "Error while loading recalled msgs from db: " + e . toString ( ) ,
122+ ", stop load."
123+ ) ;
124+ } ) ;
125+ }
126+
127+ async function loadDb ( ) {
128+ if ( nowConfig . saveDb ) {
129+ output ( "Loading recalled msgs from db..." ) ;
130+ var counter = 0 ;
131+ for await ( const value of db . values ( ) ) {
132+ counter ++ ;
133+ recalledMsg . push ( value ) ;
134+ if ( value . msg == null ) continue ;
135+ for ( item of value . msg . elements ) {
136+ if ( item . picElement != null ) {
137+ item . picElement . thumbPath = new Map ( [
138+ [
139+ 0 ,
140+ item . picElement . sourcePath
141+ . replace ( "Ori" , "Thumb" )
142+ . replace (
143+ item . picElement . md5HexStr ,
144+ item . picElement . md5HexStr + "_0"
145+ )
146+ ] ,
147+ [
148+ 198 ,
149+ item . picElement . sourcePath
150+ . replace ( "Ori" , "Thumb" )
151+ . replace (
152+ item . picElement . md5HexStr ,
153+ item . picElement . md5HexStr + "_198"
154+ )
155+ ] ,
156+ [
157+ 720 ,
158+ item . picElement . sourcePath
159+ . replace ( "Ori" , "Thumb" )
160+ . replace (
161+ item . picElement . md5HexStr ,
162+ item . picElement . md5HexStr + "_720"
163+ )
164+ ]
165+ ] ) ;
151166 }
152167 }
153- output ( `Loaded ${ counter } msgs.` ) ;
154- } else {
155- output ( "Db saving is disabled, continue." ) ;
156168 }
157- } ) ( ) . catch ( ( e ) => {
158- output ( "Error while loading recalled msgs from db: " + e . toString ( ) ) ;
159- } ) ;
169+ output ( `Loaded ${ counter } msgs.` ) ;
170+ } else {
171+ output ( "Db saving is disabled, continue." ) ;
172+ }
160173}
161174
162175var msgFlow = [ ] ;
0 commit comments