Summary: | Konq deletes files when dragging | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Christoph Eckert <ce> |
Component: | general | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | grave | CC: | kdebugs |
Priority: | NOR | ||
Version: | 3.1.4 | ||
Target Milestone: | --- | ||
Platform: | Mandrake RPMs | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Christoph Eckert
2004-01-25 01:41:35 UTC
Same happens in version 3.1.3. As said above, this action is not common but has the potential of wiping a lot ot work :( Please consider as higher priority. This is also reproducable in KDE 3.2 RC1. CVS commit by adawit: - Remove redundant KDE_stat call in FileProtocol::stat. - When copying or moving if the source exists as a symlink at the destination, remove it first to avoid the scenario where the symlink is pointing to the current source. Fixes BR# 73440. CCMAIL: 73440-done@bugs.kde.org M +32 -18 file.cc 1.146 --- kdelibs/kioslave/file/file.cc #1.145:1.146 @@ -133,4 +133,7 @@ void FileProtocol::mkdir( const KURL& ur { QCString _path( QFile::encodeName(url.path())); + + kdDebug(7101) << "mkdir(): " << _path << ", permission = " << permissions << endl; + KDE_struct_stat buff; if ( KDE_stat( _path.data(), &buff ) == -1 ) { @@ -278,5 +281,5 @@ void FileProtocol::put( const KURL& url, QCString _dest_orig( QFile::encodeName(dest_orig)); - kdDebug(7101) << "Put " << dest_orig << endl; + kdDebug(7101) << "put(): " << dest_orig << ", mode=" << _mode << endl; QString dest_part( dest_orig ); @@ -285,5 +288,5 @@ void FileProtocol::put( const KURL& url, KDE_struct_stat buff_orig; - bool orig_exists = (KDE_stat( _dest_orig.data(), &buff_orig ) != -1); + bool orig_exists = (KDE_lstat( _dest_orig.data(), &buff_orig ) != -1); bool part_exists = false; bool bMarkPartial = config()->readBoolEntry("MarkPartial", true); @@ -443,4 +446,10 @@ void FileProtocol::put( const KURL& url, if ( bMarkPartial ) { + // If the original URL is a symlink and we were asked to overwrite it, + // remove the symlink first. This ensures that we do not overwrite the + // current source if the symlink points to it. + if( _overwrite && S_ISLNK( buff_orig.st_mode ) ) + remove( _dest_orig.data() ); + if ( ::rename( _dest.data(), _dest_orig.data() ) ) { @@ -470,4 +479,6 @@ void FileProtocol::copy( const KURL &src int _mode, bool _overwrite ) { + kdDebug(7101) << "copy(): " << src << " -> " << dest << ", mode=" << _mode << endl; + QCString _src( QFile::encodeName(src.path())); QCString _dest( QFile::encodeName(dest.path())); @@ -491,5 +502,5 @@ void FileProtocol::copy( const KURL &src KDE_struct_stat buff_dest; - bool dest_exists = ( KDE_stat( _dest.data(), &buff_dest ) != -1 ); + bool dest_exists = ( KDE_lstat( _dest.data(), &buff_dest ) != -1 ); if ( dest_exists ) { @@ -505,4 +516,13 @@ void FileProtocol::copy( const KURL &src return; } + + // If the destination is a symlink and overwrite is TRUE, + // remove the symlink first to prevent the scenario where + // the symlink actually points to current source! + if (_overwrite && S_ISLNK(buff_dest.st_mode)) + { + kdDebug(7101) << "copy(): LINK DESTINATION" << endl; + remove( _dest.data() ); + } } @@ -824,5 +844,5 @@ bool FileProtocol::createUDSEntry( const } } else { - kdWarning() << "lstat didn't work on " << path.data() << endl; + // kdWarning() << "lstat didn't work on " << path.data() << endl; return false; } @@ -902,9 +922,4 @@ void FileProtocol::stat( const KURL & ur */ QCString _path( QFile::encodeName(url.path(-1))); - KDE_struct_stat buff; - if ( KDE_lstat( _path.data(), &buff ) == -1 ) { - error( KIO::ERR_DOES_NOT_EXIST, url.path(-1) ); - return; - } QString sDetails = metaData(QString::fromLatin1("details")); @@ -915,5 +930,4 @@ void FileProtocol::stat( const KURL & ur if ( !createUDSEntry( url.fileName(), _path, entry, details ) ) { - // Should never happen error( KIO::ERR_DOES_NOT_EXIST, url.path(-1) ); return; |