diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-27 18:12:41 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2016-12-27 21:43:22 +0000 |
commit | b044fc1ecd6d458980d6aa1ca815e96c22b9f973 (patch) | |
tree | 0e3bcfd9736e051b1ef25eecf7f354ab18d30f43 | |
parent | Include archive id in test info (diff) | |
download | gentoobrowse-api-b044fc1ecd6d458980d6aa1ca815e96c22b9f973.tar.bz2 gentoobrowse-api-b044fc1ecd6d458980d6aa1ca815e96c22b9f973.tar.xz gentoobrowse-api-b044fc1ecd6d458980d6aa1ca815e96c22b9f973.zip |
Support merging when applying updates that target existing packages
-rw-r--r-- | gentoobrowse-api/service/maintenance/updatesProcessor.cpp | 51 | ||||
-rw-r--r-- | gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql | 14 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest | 1 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml | 17 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 (renamed from gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1) | 0 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 | 1 | ||||
-rw-r--r-- | gentoobrowse-api/unittests/testMaintenance.cpp | 2 |
7 files changed, 51 insertions, 35 deletions
diff --git a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp index 04db644..5fd998f 100644 --- a/gentoobrowse-api/service/maintenance/updatesProcessor.cpp +++ b/gentoobrowse-api/service/maintenance/updatesProcessor.cpp @@ -10,6 +10,8 @@ #include <sql/maintenance/updatesPackageDirFiles.sql.h> #include <sql/maintenance/updatesMD5CacheFiles.sql.h> #include <sql/maintenance/updatesMovePackages.sql.h> +#include <sql/maintenance/updatesMoveUserPackages.sql.h> +#include <sql/portage/findPackage.sql.h> using namespace AdHoc::FileUtils; @@ -25,7 +27,9 @@ namespace Gentoo { UpdatesPatch(DB::Connection * db) : movePackageDirFiles(db->modify(sql::maintenance::updatesPackageDirFiles.getSql())), moveMD5CacheFiles(db->modify(sql::maintenance::updatesMD5CacheFiles.getSql())), + findPackage(db->select(sql::portage::findPackage.getSql())), movePackages(db->modify(sql::maintenance::updatesMovePackages.getSql())), + moveUserPackages(db->modify(sql::maintenance::updatesMoveUserPackages.getSql())), updatePacks("updatePack") { this->src = Utils::Database::emptyClone(db, "gentoobrowse.updates"); @@ -53,29 +57,44 @@ namespace Gentoo { DB::ModifyCommandPtr drop; DB::ModifyCommandPtr movePackageDirFiles; DB::ModifyCommandPtr moveMD5CacheFiles; + DB::SelectCommandPtr findPackage; DB::ModifyCommandPtr movePackages; + DB::ModifyCommandPtr moveUserPackages; Utils::EntityWhereFilter<std::string> updatePacks; void move(DB::SelectCommandPtr s) { s->forEachRow<std::string, std::string, std::string, std::string, std::string>([this](auto catfrom, auto catto, auto namefrom, auto nameto, auto) { - movePackageDirFiles->bindParamS(0, catto); - movePackageDirFiles->bindParamS(1, nameto); - movePackageDirFiles->bindParamS(2, catfrom); - movePackageDirFiles->bindParamS(3, namefrom); - movePackageDirFiles->execute(); - moveMD5CacheFiles->bindParamS(0, catto); - moveMD5CacheFiles->bindParamS(1, namefrom); - moveMD5CacheFiles->bindParamS(2, nameto); - moveMD5CacheFiles->bindParamS(3, catfrom); - moveMD5CacheFiles->bindParamS(4, namefrom); - moveMD5CacheFiles->execute(); - movePackages->bindParamS(0, nameto); - movePackages->bindParamS(1, namefrom); - movePackages->bindParamS(2, catfrom); - movePackages->bindParamS(3, catto); - movePackages->execute(); + findPackage->bindParamS(0, catto); + findPackage->bindParamS(1, nameto); + if (findPackage->fetch()) { // Does target already exist? + // Merge + moveUserPackages->bindParamS(0, catfrom); + moveUserPackages->bindParamS(1, namefrom); + moveUserPackages->bindParamS(2, catto); + moveUserPackages->bindParamS(3, nameto); + moveUserPackages->execute(); + } + else { + // Move + movePackageDirFiles->bindParamS(0, catto); + movePackageDirFiles->bindParamS(1, nameto); + movePackageDirFiles->bindParamS(2, catfrom); + movePackageDirFiles->bindParamS(3, namefrom); + movePackageDirFiles->execute(); + moveMD5CacheFiles->bindParamS(0, catto); + moveMD5CacheFiles->bindParamS(1, namefrom); + moveMD5CacheFiles->bindParamS(2, nameto); + moveMD5CacheFiles->bindParamS(3, catfrom); + moveMD5CacheFiles->bindParamS(4, namefrom); + moveMD5CacheFiles->execute(); + movePackages->bindParamS(0, nameto); + movePackages->bindParamS(1, namefrom); + movePackages->bindParamS(2, catfrom); + movePackages->bindParamS(3, catto); + movePackages->execute(); + } }); } }; diff --git a/gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql b/gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql new file mode 100644 index 0000000..e305ac7 --- /dev/null +++ b/gentoobrowse-api/service/sql/maintenance/updatesMoveUserPackages.sql @@ -0,0 +1,14 @@ +UPDATE gentoobrowse.user_packages up SET + packageid = np.packageid +FROM gentoobrowse.packages op, gentoobrowse.packages np, gentoobrowse.categories oc, gentoobrowse.categories nc +WHERE up.packageid = op.packageid +AND op.categoryid = oc.categoryid +AND np.categoryid = nc.categoryid +AND oc.name = ? +AND op.name = ? +AND nc.name = ? +AND np.name = ? +AND NOT EXISTS ( + SELECT FROM gentoobrowse.user_packages eup + WHERE up.userid = eup.userid + AND np.packageid = eup.packageid) diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest deleted file mode 100644 index e377aca..0000000 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/Manifest +++ /dev/null @@ -1 +0,0 @@ -DIST backintime-1.1.8.tar.gz 617754 SHA256 a1f2d210e95633dfe383eb50b3b560d1e09c43de4ce89dd4cb193cab40cb8a1e SHA512 550e270dcf341ec5ad952f4decd836007d19ff9bf60cada834dfb488dbf29954b6fd3ed80a4f8fb4406a0166895a7f7c922e5622d06c43086dd54073e5aabd99 WHIRLPOOL ea9af3c432c61def4214e1d1e2c70e40cb7e50867bb0fa08930740c13133293ad135fd6c97295ab176deaedacb33e72583dc7c34dcfc3cb375a8b6e7fc7ab632 diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml deleted file mode 100644 index c5512af..0000000 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/app-backup/backintime/metadata.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> -<pkgmetadata> - <maintainer type="person"> - <email>xmw@gentoo.org</email> - <name>Michael Weber</name> - </maintainer> - <longdescription lang="en"> -Back In Time is a simple backup tool for Linux inspired from “flyback project” and “TimeVault”. The backup is done by taking snapshots of a specified set of directories. -Currently there are two GUI available: Gnome and KDE 4 (>= 4.1). - -All you have to do is configure: - Where to save snapshot - What directories to backup - When backup should be done (manual, every hour, every day, every week, every month) -</longdescription> -</pkgmetadata> diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1 b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 index ac07dcf..ac07dcf 100644 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/app-backup/backintime-1.1.8-r1 +++ b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/metadata/md5-cache/dev-vcs/wasamanda-1.1.8-r1 diff --git a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 index dc38e7b..96442b9 100644 --- a/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 +++ b/gentoobrowse-api/unittests/fixtures/756569aa764177340726dd3d40b41d89b11b20c7/profiles/updates/4Q-2016 @@ -1,3 +1,4 @@ slotmove a/b 0 1 move app-backup/amanda dev-vcs/wasamanda move doesnt/exist some/thing +move app-backup/backintime dev-vcs/wasamanda diff --git a/gentoobrowse-api/unittests/testMaintenance.cpp b/gentoobrowse-api/unittests/testMaintenance.cpp index d864659..4c3bffe 100644 --- a/gentoobrowse-api/unittests/testMaintenance.cpp +++ b/gentoobrowse-api/unittests/testMaintenance.cpp @@ -108,7 +108,7 @@ BOOST_AUTO_TEST_CASE( refreshPackageTree ) m, 2080, 5, 1, 482, 981, 3626, 4593, 501, 393, 238, 50, 1573, 2008, 1543, 81, 152); doRefreshPackageTree(sd, db, "756569aa764177340726dd3d40b41d89b11b20c7", "gentoo", - m, 2084, 5, 1, 484, 982, 3638, 4599, 503, 393, 238, 50, 1573, 2009, 1546, 79, 152); + m, 2082, 5, 1, 483, 982, 3638, 4599, 502, 393, 238, 50, 1573, 2009, 1546, 79, 152); doRefreshPackageTree(sd, db, "", "gentoo", m, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |