KIO errors (CVS HEAD)

Andras Mantia amantia at kde.org
Mon Jun 14 16:19:40 BST 2004


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've tried to workaround the above by using:
 KTempFile *tempFile = new KTempFile(tmpDir);
 tempFile->setAutoDelete(true);
 tempFile->close(); (tried also without this line)
 KURL tmpURL = KURL::fromPathOrURL(tempFile->name());

//loop begin
 KIO::NetAccess::file_copy(absUrl, tmpURL, -1, true, true, this);
 QFile f(tempFile->name());
 if (!f.open(IO_ReadOnly))
     kdDebug(24000) << "Cannot open: " << f.name() << ". The error was: 
" << f.errorString() << endl;
 else {
   f.close();
 }
//loop end

 tempFile->unlink();

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.

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().
I think the problem is somewhere deeper in the code. Oh, I forgot, I've 
used the FTP protocol here. With fish it just hangs sometime. sftp 
seems to be OK regarding both bugs. So what can be the problem here?

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.

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/20040614/9daeb807/attachment.sig>


More information about the kde-core-devel mailing list