]> Some of my projects - localmylist.git/commitdiff
Do not remove watched directories.
authorAPTX <marek321@gmail.com>
Fri, 26 Apr 2013 19:53:48 +0000 (21:53 +0200)
committerAPTX <marek321@gmail.com>
Fri, 26 Apr 2013 19:53:48 +0000 (21:53 +0200)
localmylist/renamehandler.cpp

index a3c6ef5bd82a2af1b5b004d206ca869d95e4c4fc..75fc24a2ab68422bb0ed54b891beb01b9eab054b 100644 (file)
@@ -56,6 +56,8 @@ void RenameHandler::handleRename()
 
        t.commit();
 
+       QStringList watchedDirectories = db->getWatchedDirectories(MyList::instance()->hostId());
+
        while (q.next())
        {
                QSqlRecord r = q.record();
@@ -184,6 +186,12 @@ void RenameHandler::handleRename()
                dir.setFilter(QDir::NoDotAndDotDot | QDir::AllEntries);
                while (!dir.count())
                {
+                       for (const QString &path : watchedDirectories)
+                       {
+                               QDir watchedDirectory(path);
+                               if (dir.canonicalPath() == watchedDirectory.canonicalPath())
+                                       goto endDirRemove;
+                       }
                        // QDir::rmdir only removes empty directories
                        if (!dir.rmdir(dir.canonicalPath()))
                        {
@@ -193,6 +201,7 @@ void RenameHandler::handleRename()
                        if (!dir.cdUp())
                                break;
                }
+endDirRemove: ;
        }
 
        emit renameBatchFinished();