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

List:       kde-commits
Subject:    branches/KDE/4.4/kdelibs/kio/kio
From:       David Faure <faure () kde ! org>
Date:       2010-03-30 19:13:00
Message-ID: 20100330191300.4F4F2AC887 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1109205 by dfaure:

Backport both fixes for renaming-on-VFAT
Fixed for: 4.4.2
BUG: 162358


 M  +27 -20    copyjob.cpp  


--- branches/KDE/4.4/kdelibs/kio/kio/copyjob.cpp #1109204:1109205
@@ -20,6 +20,7 @@
 */
 
 #include "copyjob.h"
+#include <errno.h>
 #include "kdirlister.h"
 #include "kfileitem.h"
 #include "deletejob.h"
@@ -1700,28 +1701,34 @@
             kDebug(7007) << "Couldn't rename directly, dest already exists. Detected \
special case of lower/uppercase renaming in same dir, try with 2 rename calls";  \
const QString _src( m_currentSrcURL.toLocalFile() );  const QString _dest( \
dest.toLocalFile() ); +            const QString _tmpPrefix = \
m_currentSrcURL.directory(KUrl::ObeyTrailingSlash|KUrl::AppendTrailingSlash);  \
                KTemporaryFile tmpFile;
-            tmpFile.setPrefix(m_currentSrcURL.directory(KUrl::ObeyTrailingSlash));
-            tmpFile.setAutoRemove(false);
-            tmpFile.open();
-            const QString _tmp( tmpFile.fileName() );
-            kDebug(7007) << "KTemporaryFile using" << _tmp << "as intermediary";
-            if ( KDE::rename( _src, _tmp ) == 0 )
-            {
-                if ( !QFile::exists( _dest ) && KDE::rename( _tmp, _dest ) == 0 )
-                {
-                    kDebug(7007) << "Success.";
-                    err = 0;
-                }
-                else
-                {
-                    // Revert back to original name!
-                    if ( KDE::rename( _tmp, _src ) != 0 ) {
-                        kError(7007) << "Couldn't rename" << _tmp << "back to" << \
                _src << '!';
-                        // Severe error, abort
-                        q->Job::slotResult( job ); // will set the error and emit \
                result(this)
-                        return;
+            tmpFile.setPrefix(_tmpPrefix);
+            const bool openOk = tmpFile.open();
+            if (!openOk) {
+                kWarning(7007) << "Couldn't open temp file in" << _tmpPrefix;
+            } else {
+                const QString _tmp( tmpFile.fileName() );
+                tmpFile.close();
+                tmpFile.remove();
+                kDebug(7007) << "KTemporaryFile using" << _tmp << "as intermediary";
+                if (KDE::rename( _src, _tmp ) == 0) {
+                    //kDebug(7007) << "Renaming" << _src << "to" << _tmp << \
"succeeded"; +                    if (!QFile::exists( _dest ) && KDE::rename(_tmp, \
_dest) == 0) { +                        err = 0;
+                        org::kde::KDirNotify::emitFileRenamed(m_currentSrcURL.url(), \
dest.url()); +                    } else {
+                        kDebug(7007) << "Didn't manage to rename" << _tmp << "to" << \
_dest << ", reverting"; +                        // Revert back to original name!
+                        if (KDE::rename( _tmp, _src ) != 0) {
+                            kError(7007) << "Couldn't rename" << _tmp << "back to" \
<< _src << '!'; +                            // Severe error, abort
+                            q->Job::slotResult(job); // will set the error and emit \
result(this) +                            return;
+                        }
                     }
+                } else {
+                    kDebug(7007) << "mv" << _src << _tmp << "failed:" << \
strerror(errno);  }
             }
         }


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

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