KIO errors (CVS HEAD)

David Faure faure at kde.org
Mon Jun 14 21:54:52 BST 2004


On Monday 14 June 2004 17:19, Andras Mantia wrote:
> Hi,
> 
>  Today I encountered two KIO::NetAccess errors. The first one is with 
> download (but affects file_copy as well), the second is with file_copy.
>  The problem with the first one is that if you do the following:
>        QString tmp;
>        KIO::NetAccess::download(absUrl, tmp, this);
>        QFile f(tmp);
>        if (!f.open(IO_ReadOnly))
>          kdDebug(24000) << "Cannot open: " << f.name() << ". The error 
> was: " << f.errorString() << endl;
>        else {
>         f.close();
>        }
>        KIO::NetAccess::removeTempFile(tmp);
> 
> From time to time you will see that the file cannot be opened, and the 
> error is "No such file or directory".

I can't think of a reason why this should happen...

> The result is the same. Sometimes the file cannot be opened. An ugly 
>       int k = 0;
>       while (!f.exists() && k < 1000000) k++;
> before f.open() usually helps.
How could it? No event processing happens in that loop, so nothing can e.g.
receive a late qt event or something. It might give time to the kio_file slave,
but there's no need for any of this since the job is done before that...
Did you write your own filesystem which delays the actual creation of the file? :-P

> The second problem appears with the second example. If the above code is 
> called for many files (but using the same temporary file, so the part 
> between //loop begin and //loop end is put inside a loop), from time to 
> time I get a "file exist, do you want to overwrite" dialog. Note that 
> "overwrite = true" above... I've even tried an f.remove() after 
> f.close().

Can't reproduce this. See test program attached.

About the dialog: that's impossible. CopyJob displays such dialogs, 
not FileCopyJob (which is more lowlevel). NetAccess::file_copy uses FileCopyJob.

> I need the following to work as there are some classes that does not 
> work with remote files (QDomDocument, KMD5) and to be network 
> transparent first I need to download the files to a temporary location.
Or to temporary memory if they're not insanely big.

Note that you can use an asynchronous KIO Job, e.g. KIO::stored_get
if you can use kdelibs-cvs-head, otherwise a KIO::get and your own 
QByteArray or tempfile. But of course fixing NetAccess first is fine :)

-- 
David Faure, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).




More information about the kde-core-devel mailing list