Summary: | Ctrl+V Paste replaces files without asking | ||
---|---|---|---|
Product: | [Frameworks and Libraries] kio | Reporter: | Lubos Lunak <l.lunak> |
Component: | general | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | critical | CC: | jens.dagerbo |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
Lubos Lunak
2003-02-14 13:01:23 UTC
Subject: Re: Ctrl+V Paste replaces files without asking
On Friday 14 February 2003 07:03, Lubos Lunak wrote:
> What |Removed |Added
> ---------------------------------------------------------------------------
>- Severity|normal |major
I think we can safely say this is a show stopper for 3.1.1 and 3.2.0.
KIO::pasteData seems like the relevant spot. It has a TODO note on this, BTW Also: shouldn't release-criticil bugs be criticial and not major? It didn't stop 3.1 :) - http://bugs.kde.org/show_bug.cgi?id=52303 I was looking to fix my old report when I found this dupe. My naive fix: --- ../kdecvs/kdelibs/kio/kio/paste.cpp 2003-02-18 04:01:50.000000000 +0100 +++ paste.cpp 2003-02-18 04:01:14.000000000 +0100 @@ -124,9 +124,14 @@ KURL myurl(u); myurl.addPath( l.text() ); + if ( KIO::NetAccess::exists( myurl, false ) ) + { + KMessageBox::error( 0l, i18n("File already exists") ); + return; + } + // We could use KIO::put here, but that would require a class // for the slotData call. With NetAcess, we can do a synchronous call. - // NOTE: upload() overwrites the destination if it exists. TODO dialog box. KTempFile tempFile; tempFile.setAutoDelete( true ); *** Bug 52303 has been marked as a duplicate of this bug. *** Subject: kdelibs/kio/kio CVS commit by staikos: CCMAIL: 54632-done@bugs.kde.org Prompt before overwriting when pasting non-files from the clipboard. The observer change is to allow a non-job to use the observer for the rename dialog. It just checks for 0L in the job parameter and avoids crashing. M +10 -6 observer.cpp 1.48 M +26 -1 paste.cpp 1.40 --- kdelibs/kio/kio/observer.cpp #1.47:1.48 @@ -375,10 +375,14 @@ RenameDlg_Result Observer::open_RenameDl ) { - kdDebug(KDEBUG_OBSERVER) << "Observer::open_RenameDlg job=" << job << " progressId=" << job->progressId() << endl; + kdDebug(KDEBUG_OBSERVER) << "Observer::open_RenameDlg job=" << job << " progressId=" << (job ? job->progressId() : "?") << endl; // Hide existing dialog box if any + if (job) m_uiserver->setJobVisible( job->progressId(), false ); // We now do it in process. - RenameDlg_Result res = KIO::open_RenameDlg( caption, src, dest, mode, newDest, sizeSrc, sizeDest, - ctimeSrc, ctimeDest, mtimeSrc, mtimeDest ); + RenameDlg_Result res = KIO::open_RenameDlg( caption, src, dest, mode, + newDest, sizeSrc, sizeDest, + ctimeSrc, ctimeDest, mtimeSrc, + mtimeDest ); + if (job) m_uiserver->setJobVisible( job->progressId(), true ); return res; --- kdelibs/kio/kio/paste.cpp #1.39:1.40 @@ -21,4 +21,7 @@ #include "kio/global.h" #include "kio/netaccess.h" +#include "kio/observer.h" +#include "kio/renamedlg.h" +#include "kio/kprotocolmanager.h" #include <qapplication.h> @@ -125,7 +128,29 @@ void KIO::pasteData( const KURL& u, cons myurl.addPath( l.text() ); + if (KIO::NetAccess::exists(myurl, false)) + { + kdDebug(7007) << "Paste will overwrite file. Prompting..." << endl; + RenameDlg_Result res = R_OVERWRITE; + + QString newPath; + // Ask confirmation about resuming previous transfer + res = Observer::self()->open_RenameDlg( + 0L, i18n("File Already Exists"), + u.prettyURL(0, KURL::StripFileProtocol), + myurl.prettyURL(0, KURL::StripFileProtocol), + (RenameDlg_Mode) (M_OVERWRITE | M_SINGLE), newPath); + + if ( res == R_RENAME ) + { + myurl = newPath; + } + else if ( res == R_CANCEL ) + { + return; + } + } + // We could use KIO::put here, but that would require a class // for the slotData call. With NetAcess, we can do a synchronous call. - // NOTE: upload() overwrites the destination if it exists. TODO dialog box. KTempFile tempFile; |