mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kinit: different take on duplicate URLs
to not pass temporary files more than once to programs Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
07b318f9ac
commit
cea5737e95
1 changed files with 21 additions and 4 deletions
|
@ -396,11 +396,28 @@ bool KLauncherAdaptor::start_service_by_storage_id(const QString &serviceName,
|
|||
}
|
||||
kDebug() << "downloaded" << prettyurl << "to" << urldestination;
|
||||
downloaded.insert(urldestination, realurl);
|
||||
// URLs may not be unique
|
||||
int indexofurl = programandargs.indexOf(url);
|
||||
while (indexofurl != -1) {
|
||||
// URLs may not be unique, don't download more than once
|
||||
const int indexofurl = programandargs.indexOf(url);
|
||||
if (indexofurl == -1) {
|
||||
// this should never happen but warn just in case
|
||||
kWarning() << "could not find the index of" << url;
|
||||
} else {
|
||||
programandargs.replace(indexofurl, urldestination);
|
||||
indexofurl = programandargs.indexOf(url);
|
||||
bool isfirst = true;
|
||||
QMutableListIterator<QString> iter(programandargs);
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next() == url) {
|
||||
if (isfirst) {
|
||||
// first already replaced
|
||||
isfirst = false;
|
||||
continue;
|
||||
} else {
|
||||
// every other occurance is removed
|
||||
kDebug() << "removing duplicate of downloaded URL" << url;
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue