Revision 6368bb51 src/market/MarketPlaceManagerDriver.cc

View differences:

src/market/MarketPlaceManagerDriver.cc
120 120
        return;
121 121
    }
122 122

  
123
    std::string   name;
124 123
    MarketPlace * market = marketpool->get(id, true);
125 124

  
126 125
    if (market == 0 )
......
128 127
        return;
129 128
    }
130 129

  
131
    name    = market->get_name();
130
    set<int> apps_mp = market->get_marketapp_ids();
131
    std::string name = market->get_name();
132 132

  
133 133
    market->update_monitor(monitor_data);
134 134

  
......
143 143

  
144 144
    for (int i=0; i< num ; i++)
145 145
    {
146
        int rc = apppool->import(apps[i]->value(), id, name, err);
146
        int app_id;
147
        int rc = apppool->import(apps[i]->value(), id, name, app_id, err);
147 148

  
148 149
        if ( rc == -1 )
149 150
        {
......
162 163
                market->unlock();
163 164
            }
164 165
        }
165
    }
166
    MarketPlaceApp *mp_app = nullptr;
167
    std::string error;
168
    std::string source;
169
    int rc_del;
170
    market = marketpool->get(id, true);
171
    set<int> apps_mp = market->get_marketapp_ids();
172
    market->unlock();
173 166

  
174
    for (set<int>::iterator i = apps_mp.begin(); i != apps_mp.end(); i++) {
175
        mp_app = apppool->get(*i, true);
176
        if ( mp_app != 0 )
177
        {
178
            if(apppool->test_map_check(mp_app->get_name())){ //delete app
179
                market = marketpool->get(id, true);
167
        apppool->reset_map_check(app_id);
180 168

  
181
                source = mp_app->get_source();
182
                rc_del = apppool->drop(mp_app, error);
169
        apps_mp.erase(app_id);
170
    }
183 171

  
184
                market->del_marketapp(*i);
185
                marketpool->update(market);
172
    for (set<int>::iterator i = apps_mp.begin(); i != apps_mp.end(); ++i)
173
    {
174
        if (apppool->test_map_check(*i)) //delete app
175
        { 
176
            std::string error;
186 177

  
187
                market->unlock();
188
                if ( rc_del < 0 )
189
                {
190
                    oss << " Error removing app from DB: " << error
191
                        << ". Remove app manually, source is: " << source;
192
                }
178
            MarketPlaceApp * app = apppool->get(*i, true);
179

  
180
            if ( app == 0 )
181
            {
182
                continue;
193 183
            }
184

  
185
            rc = apppool->drop(app, error);
186

  
187
            app->unlock();
188

  
189
            market = marketpool->get(id, true);
190

  
191
            market->del_marketapp(*i);
192

  
193
            marketpool->update(market);
194

  
195
            market->unlock();
194 196
        }
195
        mp_app->unlock();
196 197
    }
197 198

  
198 199
    oss << "Marketplace " << name << " (" << id << ") successfully monitored.";

Also available in: Unified diff