using namespace WrtDB;
namespace {
+const char* const NPRUNTIME_PLUGINS_DIR = "plugins/";
+
struct PathAndFilePair
{
std::string path;
position),
filePath.substr(position + 1));
}
+
+inline bool isNPPlugin(const std::string& filePath)
+{
+ std::string::size_type pos = filePath.find(NPRUNTIME_PLUGINS_DIR);
+ // Not specified if a plug-in name MUST end with a specific extension
+ // (e.g. .so)
+ return ((std::string::npos != pos) &&
+ ('/' != filePath[filePath.length() - 1]));
+}
+
+// precondition: isNPPlugin(filePath) == true
+inline bool isValidNPPlugin(const std::string& filePath)
+{
+ return (filePath.find(GlobalConfig::GetNPRuntimePluginsPath()) == 0);
+}
+
+bool shouldBeInstalled(const std::string& filePath)
+{
+ if (isNPPlugin(filePath))
+ {
+ if (!isValidNPPlugin(filePath))
+ {
+ LogDebug("Not a valid NPRuntime plug-in: " << filePath);
+ return false;
+ }
+ }
+ return true;
+}
}
namespace Jobs {
// Extract file or path
std::string fileName = m_zipIterator->name;
- if (fileName[fileName.size() - 1] == '/') {
- // This is path
- std::string newPath = destination + "/" +
- fileName.substr(0, fileName.size() - 1);
- LogPedantic("Path to extract: " << newPath);
-
- // Create path in case of it is empty
- createTempPath(newPath);
- } else {
- // This is regular file
- std::string fileExtractPath = destination + "/" + fileName;
-
- LogPedantic("File to extract: " << fileExtractPath);
-
- // Split into pat & file pair
- PathAndFilePair pathAndFile = SplitFileAndPath(fileExtractPath);
-
- LogPedantic("Path and file: " <<
- pathAndFile.path <<
- " : " << pathAndFile.file);
-
- // First, ensure that path exists
- createTempPath(pathAndFile.path);
-
- Try
- {
- // Open file
- std::unique_ptr<DPL::ZipInput::File> file(
- m_zip->OpenFile(fileName));
-
- // Extract single file
- ExtractFile(file.get(), fileExtractPath);
- }
- Catch(DPL::ZipInput::Exception::OpenFileFailed)
- {
- ThrowMsg(Exceptions::ExtractFileFailed, fileName);
+ if (shouldBeInstalled(m_zipIterator->name))
+ {
+ if (fileName[fileName.size() - 1] == '/') {
+ // This is path
+ std::string newPath = destination + "/" +
+ fileName.substr(0, fileName.size() - 1);
+ LogPedantic("Path to extract: " << newPath);
+
+ // Create path in case of it is empty
+ createTempPath(newPath);
+ } else {
+ // This is regular file
+ std::string fileExtractPath = destination + "/" + fileName;
+
+ LogPedantic("File to extract: " << fileExtractPath);
+
+ // Split into pat & file pair
+ PathAndFilePair pathAndFile = SplitFileAndPath(fileExtractPath);
+
+ LogPedantic("Path and file: " <<
+ pathAndFile.path <<
+ " : " << pathAndFile.file);
+
+ // First, ensure that path exists
+ createTempPath(pathAndFile.path);
+
+ Try
+ {
+ // Open file
+ std::unique_ptr<DPL::ZipInput::File> file(
+ m_zip->OpenFile(fileName));
+
+ // Extract single file
+ ExtractFile(file.get(), fileExtractPath);
+ }
+ Catch(DPL::ZipInput::Exception::OpenFileFailed)
+ {
+ ThrowMsg(Exceptions::ExtractFileFailed, fileName);
+ }
}
}
+ else
+ {
+ LogDebug("Skipping file: " << m_zipIterator->name);
+ }
// Check whether there are more files to extract
if (++m_zipIterator == m_zip->end()) {