KIO errors (CVS HEAD)
Andras Mantia
amantia at kde.org
Mon Jun 14 22:21:22 BST 2004
On Monday 14 June 2004 23:54, David Faure wrote:
> 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...
I know this is strange, but it happens. I forgot to tell you that when
the error happens the temporary file is not removed with the
KIO::NetAccess::removeTempFile(tmp).
>
> > 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
I use SuSE 9.1 with it's standard reiserfs (don't know which version).
But it doesn't look like a filesystem bug, as it constantly happens
with the FTP ioslave, but I couldn't reproduce with sftp (nor with the
file ioslave, as the code is executed for local files as well).
> > 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.
I don't have any attachement, but I would try out to see if I can
reproduce it here or not.
> About the dialog: that's impossible.
In that case I'm seeing the impossible here. ;-) Some kind of twilight
zone.
> 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.
Well, I don't know how big they are. Normally they shouldn't be very
big, but you can never know what kind of file somebody is using in its
web project...
> 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
> :)
Sincerely, I'd like to avoid the asynch KIO job here. It just
complicates the code and in the end I would use the same hack as it's
in NetAccess to convert the asynch job into a synchronous one.
So, send me your test program and I'll give you my results.
Andras
--
Quanta Plus developer - http://quanta.sourceforge.net
K Desktop Environment - http://www.kde.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20040615/d16e442c/attachment.sig>
More information about the kde-core-devel
mailing list