[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    KIO errors (CVS HEAD)
From:       Andras Mantia <amantia () kde ! org>
Date:       2004-06-14 15:19:40
Message-ID: 200406141819.46471.amantia () kde ! org
[Download RAW message or body]


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

[Attachment #3 (application/pgp-signature)]

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic