[Bug 171479] New: Moving the desktop directory doesn't check if the destination directory is a subdirectory of the orginial

Martin Berglund mabe02 at kth.se
Mon Sep 22 22:06:28 BST 2008


http://bugs.kde.org/show_bug.cgi?id=171479

           Summary: Moving the desktop directory doesn't check if the
                    destination directory is a subdirectory of the orginial
           Product: systemsettings
           Version: 4.1
          Platform: Compiled Sources
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: unassigned-bugs at kde.org
        ReportedBy: mabe02 at kth.se


Version:            (using Devel)
Compiler:          G++ 4.2.3 
OS:                Linux
Installed from:    Compiled sources

In System Settings -> About Me -> Paths, I tried to correct a previous mistake
when I had earlier set the desktop (or was is Documents?) path to my home dir
(~). I changed it to ~/Desktop and I was asked if I wanted to move my files in
the desktop directory to the new location. I clicked "Move" before I realized I
probably shouldn't and then suddenly KDE started behaving in weird ways. The
reason was, of course, that my .kde4 and all my other files and directories in
~ had been moved to ~/Desktop until the system tried to move ~/Desktop to
~/Desktop/ which didn't work (and crashed there perhaps? I didn't check the
logs).

Anyway, I thought a simple check making sure the new directory isn't a
subdirectory of the previous one would be quite easy and here's a patch (see
below).

I wasn't sure if I chose the right component for the bug reporting, for the
user it's a part of System Settings, but I found the code in konqueror (took me
a while to find it...). Still, reporting this as a konqueror bug seems a bit
far fetched.

Oh, and, if this gets accepted, it will be my first contribution to any open
source project. Anyway, here's my patch:

Index: apps/konqueror/settings/konq/globalpaths.cpp
===================================================================
--- apps/konqueror/settings/konq/globalpaths.cpp        (revision 863683)
+++ apps/konqueror/settings/konq/globalpaths.cpp        (working copy)
@@ -288,6 +288,12 @@
     if (!src.isLocalFile() || !dest.isLocalFile())
         return true;
     m_ok = true;
+
+    // If dest is a subfolder of src, NEVER move the files 
+    // and directories of src to dest. It won't work, so don't bother asking.
+    if ( src.isParentOf(dest) )
+        return m_ok;    // always true
+
     // Ask for confirmation before moving the files
     if ( KMessageBox::questionYesNo( this, i18n("The path for '%1' has been
changed;\ndo you want the files to be moved from '%2' to '%3'?",
                               type, src.path(), dest.path()),
i18n("Confirmation Required"),KGuiItem(i18n("Move")),KStandardGuiItem::cancel()
)


-- 
Configure bugmail: http://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the Unassigned-bugs mailing list