Commit 6bfc7315 authored by Jonathan Thomas's avatar Jonathan Thomas
Browse files

Fix pin file handling to compile with both old and new APT, by using a constructor

overload common to both.

Also contains a few cleanups to the pinfile handling code.

CCBUG:294442
CCMAIL:aleixpol@kde.org
parent 2e663788
......@@ -267,19 +267,17 @@ void Backend::reloadCache()
Q_FOREACH (const QString &pinName, pinFiles) {
QString pinPath;
// Handle absolute paths
// Make all paths absolute
if (!pinName.startsWith(QLatin1Char('/'))) {
pinPath = dir % pinName;
} else {
pinPath = pinName;
}
QFile pinFile(pinPath);
if (!pinFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
continue;
}
FileFd Fd(pinFile.handle(), FileFd::ReadOnly, FileFd::None);
if (!QFile::exists(pinPath))
continue;
FileFd Fd(pinPath.toUtf8().data(), FileFd::ReadOnly);
pkgTagFile tagFile(&Fd);
if (_error->PendingError()) {
......@@ -1311,7 +1309,9 @@ bool Backend::setPackagePinned(Package *package, bool pin)
} else {
pinPath = pinName;
}
QFile pinFile(pinPath);
if (!QFile::exists(pinPath))
continue;
// Open to get a file name
QTemporaryFile tempFile;
......@@ -1326,10 +1326,7 @@ bool Backend::setPackagePinned(Package *package, bool pin)
return false;
}
if (!pinFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
continue;
}
FileFd Fd(pinFile.handle(), FileFd::ReadOnly, FileFd::None);
FileFd Fd(pinPath.toUtf8().data(), FileFd::ReadOnly);
pkgTagFile tagFile(&Fd);
if (_error->PendingError()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment