Reset launcher storage before updating it

This commit is contained in:
Simon Fels 2017-01-17 18:25:36 +01:00
commit ab473fd174
3 changed files with 14 additions and 0 deletions

View file

@ -33,6 +33,14 @@ LauncherStorage::LauncherStorage(const fs::path &path,
LauncherStorage::~LauncherStorage() {}
void LauncherStorage::reset() {
if (fs::exists(path_))
fs::remove_all(path_);
if (fs::exists(icon_path_))
fs::remove_all(icon_path_);
}
void LauncherStorage::add(const Item &item) {
if (!fs::exists(path_)) fs::create_directories(path_);
if (!fs::exists(icon_path_)) fs::create_directories(icon_path_);

View file

@ -40,6 +40,7 @@ class LauncherStorage {
std::vector<char> icon;
};
void reset();
void add(const Item &item);
private:

View file

@ -99,6 +99,11 @@ void PlatformApiSkeleton::handle_window_state_update_event(
void PlatformApiSkeleton::handle_application_list_update_event(
const anbox::protobuf::bridge::ApplicationListUpdateEvent &event) {
// Remove all existing items to start from scratch for all
// applications. We may need to improve this in the future
// to guarantee correct integration into desktop environments
launcher_storage_->reset();
for (int n = 0; n < event.applications_size(); n++) {
application::LauncherStorage::Item item;