File 3_5_BRANCH-r522108.diff of Package kdelibs3

------------------------------------------------------------------------
r522108 | dfaure | 2006-03-24 14:29:00 +0100 (Fri, 24 Mar 2006) | 3 lines

Handle ERR_IDENTICAL_FILES now that kio_file (and its wrappers :) ) emit it. Patch tested by Coolo.
BUG: 123796

------------------------------------------------------------------------
Index: kio/kio/job.cpp
===================================================================
--- kio/kio/job.cpp	(revision 522107)
+++ kio/kio/job.cpp	(revision 522108)
@@ -2786,7 +2786,7 @@ void CopyJob::slotResultCreatingDirs( Jo
     {
         m_conflictError = job->error();
         if ( (m_conflictError == ERR_DIR_ALREADY_EXIST)
-             || (m_conflictError == ERR_FILE_ALREADY_EXIST) )
+             || (m_conflictError == ERR_FILE_ALREADY_EXIST) ) // can't happen?
         {
             KURL oldURL = ((SimpleJob*)job)->url();
             // Should we skip automatically ?
@@ -3050,7 +3050,8 @@ void CopyJob::slotResultCopyingFiles( Jo
             m_conflictError = job->error(); // save for later
             // Existing dest ?
             if ( ( m_conflictError == ERR_FILE_ALREADY_EXIST )
-                 || ( m_conflictError == ERR_DIR_ALREADY_EXIST ) )
+                 || ( m_conflictError == ERR_DIR_ALREADY_EXIST )
+                 || ( m_conflictError == ERR_IDENTICAL_FILES ) )
             {
                 subjobs.remove( job );
                 assert ( subjobs.isEmpty() );
@@ -3132,7 +3133,8 @@ void CopyJob::slotResultConflictCopyingF
         m_reportTimer->stop();
 
     if ( ( m_conflictError == ERR_FILE_ALREADY_EXIST )
-      || ( m_conflictError == ERR_DIR_ALREADY_EXIST ) )
+         || ( m_conflictError == ERR_DIR_ALREADY_EXIST )
+         || ( m_conflictError == ERR_IDENTICAL_FILES ) )
     {
         // Its modification time:
         time_t destmtime = (time_t)-1;
@@ -3161,6 +3163,7 @@ void CopyJob::slotResultConflictCopyingF
         // Offer overwrite only if the existing thing is a file
         // If src==dest, use "overwrite-itself"
         RenameDlg_Mode mode;
+        bool isDir = true;
 
         if( m_conflictError == ERR_DIR_ALREADY_EXIST )
             mode = (RenameDlg_Mode) 0;
@@ -3172,6 +3175,7 @@ void CopyJob::slotResultConflictCopyingF
                 mode = M_OVERWRITE_ITSELF;
             else
                 mode = M_OVERWRITE;
+            isDir = false;
         }
 
 	if ( m_bSingleFileCopy )
@@ -3179,7 +3183,7 @@ void CopyJob::slotResultConflictCopyingF
 	else
             mode = (RenameDlg_Mode) ( mode | M_MULTI | M_SKIP );
 
-        res = Observer::self()->open_RenameDlg( this, m_conflictError == ERR_FILE_ALREADY_EXIST ?
+        res = Observer::self()->open_RenameDlg( this, !isDir ?
                                 i18n("File Already Exists") : i18n("Already Exists as Folder"),
                                 (*it).uSource.url(),
                                 (*it).uDest.url(),
@@ -3602,7 +3606,9 @@ void CopyJob::slotResultRenaming( Job* j
         // In that case it's the _same_ dir, we don't want to copy+del (data loss!)
         if ( m_currentSrcURL.isLocalFile() && m_currentSrcURL.url(-1) != dest.url(-1) &&
              m_currentSrcURL.url(-1).lower() == dest.url(-1).lower() &&
-             ( err == ERR_FILE_ALREADY_EXIST || err == ERR_DIR_ALREADY_EXIST ) )
+             ( err == ERR_FILE_ALREADY_EXIST ||
+               err == ERR_DIR_ALREADY_EXIST ||
+               err == ERR_IDENTICAL_FILES ) )
         {
             kdDebug(7007) << "Couldn't rename directly, dest already exists. Detected special case of lower/uppercase renaming in same dir, try with 2 rename calls" << endl;
             QCString _src( QFile::encodeName(m_currentSrcURL.path()) );
@@ -3643,7 +3649,9 @@ void CopyJob::slotResultRenaming( Job* j
         Q_ASSERT( m_currentSrcURL == *m_currentStatSrc );
 
         // Existing dest?
-        if ( ( err == ERR_DIR_ALREADY_EXIST || err == ERR_FILE_ALREADY_EXIST )
+        if ( ( err == ERR_DIR_ALREADY_EXIST ||
+               err == ERR_FILE_ALREADY_EXIST ||
+               err == ERR_IDENTICAL_FILES )
              && isInteractive() )
         {
             if (m_reportTimer)
@@ -3693,7 +3701,7 @@ void CopyJob::slotResultRenaming( Job* j
 
                 RenameDlg_Result r = Observer::self()->open_RenameDlg(
                     this,
-                    err == ERR_FILE_ALREADY_EXIST ? i18n("File Already Exists") : i18n("Already Exists as Folder"),
+                    err != ERR_DIR_ALREADY_EXIST ? i18n("File Already Exists") : i18n("Already Exists as Folder"),
                     m_currentSrcURL.url(),
                     dest.url(),
                     mode, newPath,
openSUSE Build Service is sponsored by