[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/runtime/kioslave/trash
From:       Kevin Ottens <ervin () kde ! org>
Date:       2006-10-31 22:48:21
Message-ID: 1162334901.052746.26082.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 600817 by ervin:

Change the way we compute trash ids. It's now independent from the order we discover \
the trashes. This way it won't be necessary to wake up all disks for trash \
operations.


 M  +26 -9     trashimpl.cpp  
 M  +0 -1      trashimpl.h  


--- trunk/KDE/kdebase/runtime/kioslave/trash/trashimpl.cpp #600816:600817
@@ -31,9 +31,6 @@
 #include <kglobalsettings.h>
 #include <kfileitem.h>
 #include <kio/chmodjob.h>
-#include <solid/devicemanager.h>
-#include <solid/device.h>
-#include <solid/volume.h>
 
 #include <QApplication>
 #include <QEventLoop>
@@ -50,11 +47,17 @@
 #include <stdlib.h>
 #include <errno.h>
 
+#undef minor
+#undef major
+
+#include <solid/devicemanager.h>
+#include <solid/device.h>
+#include <solid/volume.h>
+
 TrashImpl::TrashImpl() :
     QObject(),
     m_lastErrorCode( 0 ),
     m_initStatus( InitToBeDone ),
-    m_lastId( 0 ),
     m_homeDevice( 0 ),
     m_trashDirectoriesScanned( false ),
     // not using kio_trashrc since KIO uses that one already for kio_trash
@@ -726,14 +729,27 @@
     m_topDirectories.insert( m_lastId, mountPoint );
     return m_lastId;
 #endif
-    scanTrashDirectories();
+
+    Solid::DeviceList lst = \
Solid::DeviceManager::self().findDevicesFromQuery(QString(), \
Solid::Capability::Volume, +                                                          \
"Volume.mounted == true AND Volume.mountPoint == '"+mountPoint+"'"); +    // Pretend \
we got exactly one... +    Solid::Device device = lst[0];
+
+    // new trash dir found, register it
+    id = device.as<Solid::Volume>()->major()*1000+device.as<Solid::Volume>()->minor();
 +    m_trashDirectories.insert( id, trashDir );
+    kDebug() << k_funcinfo << "found " << trashDir << " gave it id " << id << endl;
+    if ( !mountPoint.endsWith( "/" ) )
+        mountPoint += '/';
+    m_topDirectories.insert( id, mountPoint );
+
     return idForTrashDirectory( trashDir );
 }
 
 void TrashImpl::scanTrashDirectories() const
 {
     Solid::DeviceList lst = \
Solid::DeviceManager::self().findDevicesFromQuery(QString(), \
                Solid::Capability::Volume,
-                                                                              \
"Volume.mounted = true"); +                                                           \
                "Volume.mounted == true");
     for ( Solid::DeviceList::Iterator it = lst.begin() ; it != lst.end() ; ++it ) {
         QString topdir = (*it).as<Solid::Volume>()->mountPoint();
         QString trashDir = trashForMountPoint( topdir, false );
@@ -742,11 +758,12 @@
             int trashId = idForTrashDirectory( trashDir );
             if ( trashId == -1 ) {
                 // new trash dir found, register it
-                m_trashDirectories.insert( ++m_lastId, trashDir );
-                kDebug() << k_funcinfo << "found " << trashDir << " gave it id " << \
m_lastId << endl; +                trashId = \
(*it).as<Solid::Volume>()->major()*1000+(*it).as<Solid::Volume>()->minor(); +         \
m_trashDirectories.insert( trashId, trashDir ); +                kDebug() << \
k_funcinfo << "found " << trashDir << " gave it id " << trashId << endl;  if ( \
!topdir.endsWith( "/" ) )  topdir += '/';
-                m_topDirectories.insert( m_lastId, topdir );
+                m_topDirectories.insert( trashId, topdir );
             }
         }
     }
--- trunk/KDE/kdebase/runtime/kioslave/trash/trashimpl.h #600816:600817
@@ -166,7 +166,6 @@
     // The home trash has id 0.
     mutable TrashDirMap m_trashDirectories; // id -> path of trash directory
     mutable TrashDirMap m_topDirectories; // id -> $topdir of partition
-    mutable int m_lastId;
     dev_t m_homeDevice;
     mutable bool m_trashDirectoriesScanned;
     int m_mibEnum;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic