summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'shared/classes/gentoo_profile.php')
-rw-r--r--shared/classes/gentoo_profile.php12
1 files changed, 7 insertions, 5 deletions
diff --git a/shared/classes/gentoo_profile.php b/shared/classes/gentoo_profile.php
index 5657ed1..0cf071d 100644
--- a/shared/classes/gentoo_profile.php
+++ b/shared/classes/gentoo_profile.php
@@ -138,16 +138,17 @@ class sql_gentoo_profile extends sql_row_obj {
$file=realpath(BACKEND.'/../gentoo_pkgsets.csv');
if (!is_readable($file)) return false;
$file=fopen($file, 'r');
+ if ($update) $exists=array();
while (!feof($file)) {
$add=array();
- $pkgs=explode("\t", rtrim(fgets($file)));
+ $pkgs=explode("\t", trim(fgets($file)));
+ if (substr($pkgs[0], 0, 1) == '#') continue;
$name=array_shift($pkgs);
$obj=new sql_gentoo_pkgset();
if ($update) {
$r=$S['pdo']->query('SELECT * FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.' AND `name`="'.$name.'" LIMIT 1');
- if ($r->rowCount()) {
+ if ($r->rowCount())
$obj->from_array($r->fetch(PDO::FETCH_ASSOC), true);
- }
}
foreach ($pkgs as $pkg) {
if ($pkg=sql_gentoo_package::from_atom($pkg, $this))
@@ -158,10 +159,11 @@ class sql_gentoo_profile extends sql_row_obj {
$obj->name=$name;
$obj->packages=implode("\n", $add);
$obj->write();
- } elseif (isset($obj->id)) {
- $obj->delete();
+ if ($update) $exists[]=$obj->id;
}
}
+ if ($update)
+ $S['pdo']->query('DELETE FROM `gentoo_pkgsets` WHERE `profile`='.$this->id.($exists?' AND `id` NOT IN ('.implode(',', $exists).')':''));
}
public function &get_packages() {
global $S;