data urls and FileCopyJob

David Faure dfaure at klaralvdalens-datakonsult.se
Mon Sep 15 11:09:08 BST 2003


On Monday 15 September 2003 12:00, Waldo Bastian wrote:
> On Monday 15 September 2003 11:32, David Faure wrote:
> > On Monday 15 September 2003 10:04, Waldo Bastian wrote:
> > > On Sunday 14 September 2003 23:27, David Faure wrote:
> > > > This is a bug in kio_file, it tries to close(fd) even when fd==-1 due
> > > > to no data received. Please find the fix below (Waldo - ok?)
> > >
> > > Strictly speaking kio_file should then create an empty file, no? I mean
> > > if I copy a directory from one place to another I don't want to lose
> > > empty files without warning.
> >
> > Right. Ah, I see..... I got an empty file in this case, because KTempFile
> > created it. But you're right, we want an empty file even when not using
> > KTempFile.
> >
> > Why does kio_file's put() create the file on demand then? (It only opens
> > the dest when receiving the first chunk of data, I don't see why it does
> > that).
> 
> The put job can get canceled before it gets any data, e.g. because the get job
> couldn't get started, in that case it makes sense not to create any file.
> However, if the put() only gets one empty block of data (which indicates EOD)
> then it should create an empty file.

Ah, right. That's easy then

Index: file.cc
===================================================================
RCS file: /home/kde/kdelibs/kioslave/file/file.cc,v
retrieving revision 1.142
diff -u -p -r1.142 file.cc
--- file.cc     14 Sep 2003 21:29:31 -0000      1.142
+++ file.cc     15 Sep 2003 10:08:34 -0000
@@ -320,7 +320,7 @@ void FileProtocol::put( const KURL& url,
         dataReq(); // Request for data
         result = readData( buffer );

-        if (result > 0)
+        if (result >= 0)
         {
             if (dest.isEmpty())
             {

(untested, but obvious). OK for commit?

-- 
David Faure -- faure at kde.org, dfaure at klaralvdalens-datakonsult.se
Qt/KDE/KOffice developer
Klarälvdalens Datakonsult AB, Platform-independent software solutions




More information about the kfm-devel mailing list