Skip to content

Commit

Permalink
re #10811 change file deletion to be specific to avoid race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
NickDraper committed Jan 6, 2015
1 parent 92069e7 commit 1e411c8
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions Code/Mantid/Framework/DataHandling/test/DownloadInstrumentTest.h
Expand Up @@ -152,7 +152,7 @@ class DownloadInstrumentTest : public CxxTest::TestSuite
Poco::File orphanedFile(orphanedFilePath);
TSM_ASSERT("The orphaned file was not deleted",orphanedFile.exists()==false);

cleanupDiretory(localInstDir);
deleteFile(orphanedFilePath.toString());
}

int runDownloadInstrument()
Expand All @@ -171,26 +171,27 @@ class DownloadInstrumentTest : public CxxTest::TestSuite

void cleanupDiretory(std::string dir)
{
deleteFiles(dir, "*.xml");
deleteFiles(dir, "*.json");
Poco::Path path(dir);
path.makeDirectory();
deleteFile(path.setFileName("github.json").toString());
deleteFile(path.setFileName("NewFile.xml").toString());
deleteFile(path.setFileName("UpdatableFile.xml").toString());
}

size_t deleteFiles(std::string filePath, std::string pattern)
bool deleteFile(std::string filePath)
{
Poco::Path path(filePath);
path.makeDirectory();
path.setFileName(pattern);
std::set<std::string> files;
Poco::Glob::glob(path.toString(),files);
for (auto it = files.begin(); it != files.end(); ++it)
Poco::File file(filePath);
if(file.exists())
{
Poco::File file(*it);
file.remove();
return true;
}
else
{
return false;
}
return files.size();
}


};


Expand Down

0 comments on commit 1e411c8

Please sign in to comment.