Bug 107201 - Cervisia "Create patch against repository" does not confirm file overwrite
Summary: Cervisia "Create patch against repository" does not confirm file overwrite
Status: RESOLVED FIXED
Alias: None
Product: cervisia
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Gentoo Packages Linux
: NOR normal
Target Milestone: ---
Assignee: Christian Loose
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-11 05:19 UTC by Paul Eggleton
Modified: 2005-06-23 20:52 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul Eggleton 2005-06-11 05:19:32 UTC
Version:            (using KDE KDE 3.4.1)
Installed from:    Gentoo Packages
Compiler:          gcc version 3.3.5-20050130 Gentoo 3.3.5.20050130-r1, ssp-3.3.5.20050130-1, pie-8.7.7.1
OS:                Linux

If you use Cervisia's "Create patch against repository" feature, and when prompted with the file save dialog you select a file that already exists, Cervisia does not ask you if you want to overwrite the file.
Comment 1 Christian Loose 2005-06-11 12:20:35 UTC
IMHO a kdelibs problem (see Bug 102972), but I will fix it anyway until the requested feature is implemented.

Thanks for the report.
Comment 2 Christian Loose 2005-06-23 20:52:08 UTC
SVN commit 428324 by cloose:

Be nice and ask before overwriting existing files.

BUG: 107201

 M  +3 -0      cervisiapart.cpp  
 M  +3 -0      logdlg.cpp  
 M  +22 -0     misc.cpp  
 M  +2 -0      misc.h  
 M  +1 -1      resolvedlg.cpp  


--- trunk/KDE/kdesdk/cervisia/cervisiapart.cpp #428323:428324
@@ -1335,6 +1335,9 @@
     if( fileName.isEmpty() )
         return;
 
+    if( !Cervisia::CheckOverwrite(fileName) )
+        return;
+
     QFile f(fileName);
     if( !f.open(IO_WriteOnly) )
     {
--- trunk/KDE/kdesdk/cervisia/logdlg.cpp #428323:428324
@@ -466,6 +466,9 @@
     if( fileName.isEmpty() )
         return;
 
+    if( !Cervisia::CheckOverwrite(fileName) )
+        return;
+
     QFile f(fileName);
     if( !f.open(IO_WriteOnly) )
     {
--- trunk/KDE/kdesdk/cervisia/misc.cpp #428323:428324
@@ -26,11 +26,13 @@
 #include <sys/types.h>
 #include <unistd.h>
 #include <qfile.h>
+#include <qfileinfo.h>
 #include <qregexp.h>
 #include <qstringlist.h>
 #include <kconfig.h>
 #include <kemailsettings.h>
 #include <klocale.h>
+#include <kmessagebox.h>
 #include <kprocess.h>
 #include <ktempfile.h>
 #include <kuser.h>
@@ -204,6 +206,26 @@
 }
 
 
+bool Cervisia::CheckOverwrite(const QString& fileName)
+{
+    bool result = true;
+
+    QFileInfo fi(fileName);
+
+    // does the file already exist?
+    if( fi.exists() )
+    {
+        result = (KMessageBox::warningYesNo(0,
+                  i18n("A file named \"%1\" already exists. Are you sure you want to overwrite it?").arg(fileName),
+                  i18n("Overwrite File?"),
+                  KGuiItem(i18n("&Overwrite"), "filesave", i18n("Overwrite the file")),
+                  KStdGuiItem::cancel()) == KMessageBox::Yes);
+    }
+
+    return result;
+}
+
+
 QString joinLine(const QStringList &list)
 {
     QString line;
--- trunk/KDE/kdesdk/cervisia/misc.h #428323:428324
@@ -50,6 +50,8 @@
  */
 QString NormalizeRepository(const QString& repository);
 
+bool CheckOverwrite(const QString& fileName);
+
 }
 
 
--- trunk/KDE/kdesdk/cervisia/resolvedlg.cpp #428323:428324
@@ -579,7 +579,7 @@
     QString filename =
         KFileDialog::getSaveFileName(0, 0, this, 0);
 
-    if (!filename.isEmpty())
+    if( !filename.isEmpty() && Cervisia::CheckOverwrite(filename) )
         saveFile(filename);
 }