diff base/TempDirectory.cpp @ 621:58c82e10ef00

* Be more diligent about removing abandoned temporary directories: remove directories that have no .pid files
author Chris Cannam
date Fri, 12 Mar 2010 13:13:06 +0000
parents 1415e35881f6
children 29efe322ab47
line wrap: on
line diff
--- a/base/TempDirectory.cpp	Fri Mar 12 13:03:53 2010 +0000
+++ b/base/TempDirectory.cpp	Fri Mar 12 13:13:06 2010 +0000
@@ -248,7 +248,17 @@
 
     for (unsigned int i = 0; i < dir.count(); ++i) {
         
-        QDir subdir(dir.filePath(dir[i]), "*.pid", QDir::Name, QDir::Files);
+        QString dirpath = dir.filePath(dir[i]);
+
+        QDir subdir(dirpath, "*.pid", QDir::Name, QDir::Files);
+
+        if (subdir.count() == 0) {
+            std::cerr << "INFO: Found temporary directory with no .pid file in it!\n(directory=\""
+                      << dirpath.toStdString() << "\").  Removing it..." << std::endl;
+            cleanupDirectory(dirpath);
+            std::cerr << "...done." << std::endl;
+            continue;
+        }
 
         for (unsigned int j = 0; j < subdir.count(); ++j) {
 
@@ -260,9 +270,9 @@
                 std::cerr << "INFO: Found abandoned temporary directory from "
                           << "a previous, defunct process\n(pid=" << pid
                           << ", directory=\""
-                          << dir.filePath(dir[i]).toStdString()
+                          << dirpath.toStdString()
                           << "\").  Removing it..." << std::endl;
-                cleanupDirectory(dir.filePath(dir[i]));
+                cleanupDirectory(dirpath);
                 std::cerr << "...done." << std::endl;
                 break;
             }