mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kio: preserve the extension from KIO::NetAccess::download()
it was done by kioexec which KRun was using but now everything that uses KIO::NetAccess::download() benefits from better MIME type detection (e.g. inkscape used to fail to detect the image format because the temporary file was lacking extension) Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
c8304a4da7
commit
c40e6014ce
1 changed files with 25 additions and 19 deletions
|
@ -99,28 +99,34 @@ NetAccess::~NetAccess()
|
|||
|
||||
bool NetAccess::download(const KUrl& u, QString & target, QWidget* window)
|
||||
{
|
||||
if (u.isLocalFile()) {
|
||||
// file protocol. We do not need the network
|
||||
target = u.toLocalFile();
|
||||
bool accessible = KStandardDirs::checkAccess(target, R_OK);
|
||||
if(!accessible)
|
||||
{
|
||||
lastErrorMsg = i18n("File '%1' is not readable", target);
|
||||
lastErrorCode = ERR_COULD_NOT_READ;
|
||||
if (u.isLocalFile()) {
|
||||
// file protocol, do not need the network
|
||||
target = u.toLocalFile();
|
||||
bool accessible = KStandardDirs::checkAccess(target, R_OK);
|
||||
if(!accessible) {
|
||||
lastErrorMsg = i18n("File '%1' is not readable", target);
|
||||
lastErrorCode = ERR_COULD_NOT_READ;
|
||||
}
|
||||
return accessible;
|
||||
}
|
||||
return accessible;
|
||||
}
|
||||
|
||||
if (target.isEmpty())
|
||||
{
|
||||
target = KTemporaryFile::filePath();
|
||||
tmpfiles.append(target);
|
||||
}
|
||||
if (target.isEmpty()) {
|
||||
// same bits as in kparts/part.cpp
|
||||
QFileInfo fileInfo(u.fileName());
|
||||
QString ext = fileInfo.completeSuffix();
|
||||
QString extension;
|
||||
if (!ext.isEmpty() && u.query().isEmpty()) {
|
||||
// not if the URL has a query
|
||||
extension = '.' + ext;
|
||||
}
|
||||
target = KTemporaryFile::filePath(QString::fromLatin1("XXXXXXXXXX%1").arg(extension));
|
||||
tmpfiles.append(target);
|
||||
}
|
||||
|
||||
NetAccess kioNet;
|
||||
KUrl dest;
|
||||
dest.setPath( target );
|
||||
return kioNet.filecopyInternal( u, dest, -1, KIO::Overwrite, window, false /*copy*/);
|
||||
NetAccess kioNet;
|
||||
KUrl dest;
|
||||
dest.setPath( target );
|
||||
return kioNet.filecopyInternal( u, dest, -1, KIO::Overwrite, window, false /*copy*/);
|
||||
}
|
||||
|
||||
bool NetAccess::upload(const QString& src, const KUrl& target, QWidget* window)
|
||||
|
|
Loading…
Add table
Reference in a new issue