Bug 323636 - Save As overwrites file when choosing rename
Summary: Save As overwrites file when choosing rename
Status: RESOLVED FIXED
Alias: None
Product: kdepim
Classification: Unclassified
Component: messageviewer (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR normal (vote)
Target Milestone: ---
Assignee: kdepim bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-17 13:57 UTC by Albert Astals Cid
Modified: 2013-08-17 17:35 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 4.12


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Albert Astals Cid 2013-08-17 13:57:13 UTC
How to reproduce:
 * Get a mail with an attachment named Q
 * Right click on the attachment and choose save as
 * Go to a folder where you have a file named Q
 * Press Save
 * Get a dialog "there's already a file named Q"
 * Now you're going to loose your file named Q
 * Press "rename"
 * The file you had named Q is overwritten

It could be fixed by doing this

diff --git a/messageviewer/utils/util.cpp b/messageviewer/utils/util.cpp
index 18717d4..c0448e6 100644
--- a/messageviewer/utils/util.cpp
+++ b/messageviewer/utils/util.cpp
@@ -272,7 +272,7 @@ bool Util::saveContents( QWidget *parent, const QList<KMime::Content*> &contents
       if( !(result == PimCommon::RenameFileDialog::RENAMEFILE_OVERWRITEALL ||
               result == PimCommon::RenameFileDialog::RENAMEFILE_IGNOREALL ))
       {
-          if ( KIO::NetAccess::exists( curUrl, KIO::NetAccess::DestinationSide, parent ) ) {
+          while ( KIO::NetAccess::exists( curUrl, KIO::NetAccess::DestinationSide, parent ) ) {
               if ( contents.count() == 1 ) {
                   PimCommon::RenameFileDialog *dlg = new PimCommon::RenameFileDialog(curUrl,false, parent);
                   result = static_cast<PimCommon::RenameFileDialog::RenameFileDialogResult>(dlg->exec());


But probably should be fixed inside RenameFileDialog itself since there are more users like kaddressbook/ that also seem to assume that the file they get out of RenameFileDialog is good to go.
Comment 1 Laurent Montel 2013-08-17 14:24:35 UTC
Waou good test
I never think that user can do it :)
Ok will look at today.
Thanks for reporting bug. Will fix in all area.
Comment 2 Laurent Montel 2013-08-17 17:35:12 UTC
Git commit 268987b77e8a18edf49d024147e882840cbf3593 by Montel Laurent.
Committed on 17/08/2013 at 17:34.
Pushed by mlaurent into branch 'master'.

Fix Bug 323636 - Save As overwrites file when choosing rename

FIXED-IN: 4.12

M  +7    -0    pimcommon/widgets/renamefiledialog.cpp

http://commits.kde.org/kdepim/268987b77e8a18edf49d024147e882840cbf3593