Mercurial > hg > svcore
comparison 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 |
comparison
equal
deleted
inserted
replaced
620:3e139b2dfe5e | 621:58c82e10ef00 |
---|---|
246 { | 246 { |
247 QDir dir(svDir, "sv_*", QDir::Name, QDir::Dirs); | 247 QDir dir(svDir, "sv_*", QDir::Name, QDir::Dirs); |
248 | 248 |
249 for (unsigned int i = 0; i < dir.count(); ++i) { | 249 for (unsigned int i = 0; i < dir.count(); ++i) { |
250 | 250 |
251 QDir subdir(dir.filePath(dir[i]), "*.pid", QDir::Name, QDir::Files); | 251 QString dirpath = dir.filePath(dir[i]); |
252 | |
253 QDir subdir(dirpath, "*.pid", QDir::Name, QDir::Files); | |
254 | |
255 if (subdir.count() == 0) { | |
256 std::cerr << "INFO: Found temporary directory with no .pid file in it!\n(directory=\"" | |
257 << dirpath.toStdString() << "\"). Removing it..." << std::endl; | |
258 cleanupDirectory(dirpath); | |
259 std::cerr << "...done." << std::endl; | |
260 continue; | |
261 } | |
252 | 262 |
253 for (unsigned int j = 0; j < subdir.count(); ++j) { | 263 for (unsigned int j = 0; j < subdir.count(); ++j) { |
254 | 264 |
255 bool ok = false; | 265 bool ok = false; |
256 int pid = QFileInfo(subdir[j]).baseName().toInt(&ok); | 266 int pid = QFileInfo(subdir[j]).baseName().toInt(&ok); |
258 | 268 |
259 if (GetProcessStatus(pid) == ProcessNotRunning) { | 269 if (GetProcessStatus(pid) == ProcessNotRunning) { |
260 std::cerr << "INFO: Found abandoned temporary directory from " | 270 std::cerr << "INFO: Found abandoned temporary directory from " |
261 << "a previous, defunct process\n(pid=" << pid | 271 << "a previous, defunct process\n(pid=" << pid |
262 << ", directory=\"" | 272 << ", directory=\"" |
263 << dir.filePath(dir[i]).toStdString() | 273 << dirpath.toStdString() |
264 << "\"). Removing it..." << std::endl; | 274 << "\"). Removing it..." << std::endl; |
265 cleanupDirectory(dir.filePath(dir[i])); | 275 cleanupDirectory(dirpath); |
266 std::cerr << "...done." << std::endl; | 276 std::cerr << "...done." << std::endl; |
267 break; | 277 break; |
268 } | 278 } |
269 } | 279 } |
270 } | 280 } |