diff --git a/src/menu.cpp b/src/menu.cpp index 46ff483..08e3f4f 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -451,6 +451,10 @@ void Menu::setLinkIndex(int i) { #ifdef HAVE_LIBOPK void Menu::openPackage(std::string path) { + /* First try to remove existing links of the same OPK + * (needed for instance when an OPK is modified) */ + removePackageLink(path); + struct OPK *opk = opk_open(path.c_str()); if (!opk) { ERROR("Unable to open OPK %s\n", path.c_str()); @@ -544,8 +548,6 @@ void Menu::readPackages(std::string parentDir) #ifdef ENABLE_INOTIFY void Menu::removePackageLink(std::string path) { - bool found = false; - for (vector< vector >::iterator section = links.begin(); section < links.end(); section++) { for (vector::iterator link = section->begin(); @@ -561,14 +563,10 @@ void Menu::removePackageLink(std::string path) if (section - links.begin() == iSection && iLink == (int) section->size()) setLinkIndex(iLink - 1); - found = true; link--; } } } - - if (!found) - ERROR("Unable to find link corresponding to %s\n", path.c_str()); } #endif #endif diff --git a/src/monitor.cpp b/src/monitor.cpp index e0575c7..de41db2 100644 --- a/src/monitor.cpp +++ b/src/monitor.cpp @@ -24,7 +24,7 @@ static void * inotify_thd(void *p) } wd = inotify_add_watch(fd, path, IN_MOVED_FROM | IN_MOVED_TO | - IN_CLOSE_WRITE | IN_DELETE); + IN_CLOSE_WRITE | IN_DELETE | IN_CREATE); if (wd == -1) { ERROR("Unable to add inotify watch\n"); close(fd); @@ -48,7 +48,8 @@ static void * inotify_thd(void *p) SDL_UserEvent e = { .type = SDL_USEREVENT, - .code = (int) (event.mask & (IN_MOVED_TO | IN_CLOSE_WRITE)), + .code = (int) (event.mask & + (IN_MOVED_TO | IN_CLOSE_WRITE | IN_CREATE)), .data1 = strdup(buf), .data2 = NULL, };