Date:2013-07-19 01:28:44 (4 years 11 months ago)
Author:Paul Cercueil
Commit:cc869c07a8efe9e495a4125a9442156f327093b3
Message:Fix link insertion/deletion when OPKs are overwritten from SSH/FTP

Files: src/menu.cpp (3 diffs)
src/monitor.cpp (2 diffs)

Change Details

src/menu.cpp
451451#ifdef HAVE_LIBOPK
452452void Menu::openPackage(std::string path)
453453{
454    /* First try to remove existing links of the same OPK
455     * (needed for instance when an OPK is modified) */
456    removePackageLink(path);
457
454458    struct OPK *opk = opk_open(path.c_str());
455459    if (!opk) {
456460        ERROR("Unable to open OPK %s\n", path.c_str());
...... 
544548#ifdef ENABLE_INOTIFY
545549void Menu::removePackageLink(std::string path)
546550{
547    bool found = false;
548
549551    for (vector< vector<Link*> >::iterator section = links.begin();
550552                section < links.end(); section++) {
551553        for (vector<Link*>::iterator link = section->begin();
...... 
561563                if (section - links.begin() == iSection
562564                            && iLink == (int) section->size())
563565                    setLinkIndex(iLink - 1);
564                found = true;
565566                link--;
566567            }
567568        }
568569    }
569
570    if (!found)
571        ERROR("Unable to find link corresponding to %s\n", path.c_str());
572570}
573571#endif
574572#endif
src/monitor.cpp
2424    }
2525
2626    wd = inotify_add_watch(fd, path, IN_MOVED_FROM | IN_MOVED_TO |
27                IN_CLOSE_WRITE | IN_DELETE);
27                IN_CLOSE_WRITE | IN_DELETE | IN_CREATE);
2828    if (wd == -1) {
2929        ERROR("Unable to add inotify watch\n");
3030        close(fd);
...... 
4848
4949        SDL_UserEvent e = {
5050            .type = SDL_USEREVENT,
51            .code = (int) (event.mask & (IN_MOVED_TO | IN_CLOSE_WRITE)),
51            .code = (int) (event.mask &
52                        (IN_MOVED_TO | IN_CLOSE_WRITE | IN_CREATE)),
5253            .data1 = strdup(buf),
5354            .data2 = NULL,
5455        };

Archive Download the corresponding diff file



interactive