1
0
mirror of git://projects.qi-hardware.com/gmenu2x.git synced 2024-11-05 10:24:59 +02:00

Fix link insertion/deletion when OPKs are overwritten from SSH/FTP

This commit is contained in:
Paul Cercueil 2013-07-18 19:28:44 -04:00
parent 91f381fa07
commit cc869c07a8
2 changed files with 7 additions and 8 deletions

View File

@ -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<Link*> >::iterator section = links.begin();
section < links.end(); section++) {
for (vector<Link*>::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

View File

@ -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,
};