summaryrefslogtreecommitdiffstats
path: root/class/Parser.php
diff options
context:
space:
mode:
Diffstat (limited to 'class/Parser.php')
-rw-r--r--class/Parser.php45
1 files changed, 32 insertions, 13 deletions
diff --git a/class/Parser.php b/class/Parser.php
index 124b36e..3ef11a4 100644
--- a/class/Parser.php
+++ b/class/Parser.php
@@ -186,23 +186,40 @@ class Parser
}
}
if (!$TimRemote) {
- self::log("Can't read $UrlRemote");
+ self::log("Can't read " . $row['url']);
} else if ($TimRemote > $row['stamp']) {
self::log("Loading $UrlRemote");
- $fic=gzopen($UrlRemote, "r");
- if ($fic) {
- $txt="";
- while ($buf=gzread($fic, 8196)) {
- $txt .= $buf;
+ $txt = file_get_contents($UrlRemote);
+ if (!$txt) {
+ self::log("ERROR : can't read $UrlRemote");
+ } else if (str_ends_with($UrlRemote, '.xml')) {
+ // OK
+ } else if (str_ends_with($UrlRemote, '.xz')) {
+ if (function_exists('xzdecode')) {
+ $txt = xzdecode($txt);
+ } else {
+ self::log("ERROR : missing xz php extension");
+ return NULL;
}
- self::log("Read " . strlen($txt) . " bytes");
- gzclose($fic);
-
+ } else if (str_ends_with($UrlRemote, '.zst')) {
+ if (function_exists('zstd_uncompress')) {
+ $txt = zstd_uncompress($txt);
+ } else {
+ self::log("ERROR : missing zstd php extension");
+ return NULL;
+ }
+ } else if (str_ends_with($UrlRemote, '.gz')) {
+ $txt = gzdecode($txt);
+ } else {
+ self::log("ERROR : unkown compression");
+ return NULL;
+ }
+ if ($txt) {
$primary = simplexml_load_string($txt);
if ($primary) {
- self::log("Read " . $primary->attributes() . " packages");
+ self::log("Read " . $primary->attributes() . " packages from primary");
$rpmrepo->update($row['id'], array('stamp' =>$TimRemote));
return $primary;
@@ -210,7 +227,7 @@ class Parser
self::log("ERROR : can't parse $UrlRemote");
}
} else {
- self::log("ERROR : can't read $UrlRemote");
+ self::log("ERROR : can't uncompress $UrlRemote");
}
} else {
self::log("no update needed : $TimRemote / " . $row['stamp']);
@@ -261,6 +278,8 @@ class Parser
}
}
self::log("Write $tot packages");
+ } else {
+ self::log("Bad primary.xml");
}
return $tot;
}
@@ -338,7 +357,7 @@ class Parser
}
}
}
- self::log("Read $tot packages");
+ self::log("Read $tot packages for provides");
}
return $tot;
}
@@ -747,4 +766,4 @@ class Parser
}
}
-?> \ No newline at end of file
+?>