@@ -105,8 +105,7 @@ impl CoffeeManager {
105
105
. map ( |store| {
106
106
self . config = store. config ;
107
107
} ) ;
108
- // FIXME: check if this exist in a better wai
109
- let _ = self
108
+ let global_repositories = self
110
109
. storage
111
110
. load :: < HashMap < RepoName , RepositoryInfo > > ( "repositories" )
112
111
. await
@@ -120,6 +119,34 @@ impl CoffeeManager {
120
119
} ) ;
121
120
} ) ;
122
121
122
+ if let Ok ( _) = global_repositories {
123
+ // HACK: this should be done with the nurse command, but
124
+ // due that currently migrating the database with the nurse
125
+ // logic is a little bit tricky we do this hack and we try
126
+ // to move on, but if you are looking something to do in coffee
127
+ // it is possible to take this problem and design a solution.
128
+ // FIXME: add the drop method inside nosql_db
129
+ }
130
+
131
+ let local_repositories = self
132
+ . storage
133
+ . load :: < HashMap < RepoName , RepositoryInfo > > ( & format ! (
134
+ "{}/repositories" ,
135
+ self . config. network
136
+ ) )
137
+ . await ;
138
+ if let Ok ( repos) = local_repositories {
139
+ // FIXME: till we are not able to remove a key from
140
+ // the database
141
+ self . repos . clear ( ) ;
142
+ repos. iter ( ) . for_each ( |repo| match repo. 1 . kind {
143
+ Kind :: Git => {
144
+ let repo = Github :: from ( repo. 1 ) ;
145
+ self . repos . insert ( repo. name ( ) , Box :: new ( repo) ) ;
146
+ }
147
+ } ) ;
148
+ }
149
+
123
150
if let Err ( err) = self . coffee_cln_config . parse ( ) {
124
151
log:: error!( "{}" , err. cause) ;
125
152
}
@@ -192,7 +219,10 @@ impl CoffeeManager {
192
219
. store ( & self . config . network , & store_info)
193
220
. await ?;
194
221
self . storage
195
- . store ( "repositories" , & store_info. repositories )
222
+ . store (
223
+ & format ! ( "{}/repositories" , self . config. network) ,
224
+ & store_info. repositories ,
225
+ )
196
226
. await ?;
197
227
Ok ( ( ) )
198
228
}
0 commit comments