Update Dictionaries/*

This commit is contained in:
kssenii 2021-04-30 23:35:44 +03:00
parent 549b5f8a0c
commit 378195a6d8
5 changed files with 27 additions and 17 deletions

View File

@ -424,20 +424,19 @@ ConfigProcessor::Files ConfigProcessor::getConfigMergeFiles(const std::string &
for (const std::string & merge_dir_name : merge_dirs)
{
Poco::File merge_dir(merge_dir_name);
if (!merge_dir.exists() || !merge_dir.isDirectory())
fs::path merge_dir(merge_dir_name);
if (!fs::exists(merge_dir) || !is_directory(merge_dir))
continue;
for (Poco::DirectoryIterator it(merge_dir_name); it != Poco::DirectoryIterator(); ++it)
for (fs::directory_iterator it(merge_dir_name); it != fs::directory_iterator(); ++it)
{
Poco::File & file = *it;
Poco::Path path(file.path());
std::string extension = path.getExtension();
std::string base_name = path.getBaseName();
fs::path path(it->path());
std::string extension = path.extension();
std::string base_name = path.stem();
// Skip non-config and temporary files
if (file.isFile() && (extension == "xml" || extension == "conf") && !startsWith(base_name, "."))
files.push_back(file.path());
if (fs::is_regular_file(path) && (extension == ".xml" || extension == ".conf") && !startsWith(base_name, "."))
files.push_back(it->path());
}
}
@ -512,7 +511,7 @@ XMLDocumentPtr ConfigProcessor::processConfig(
else
{
std::string default_path = "/etc/metrika.xml";
if (Poco::File(default_path).exists())
if (fs::exists(default_path))
include_from_path = default_path;
}
if (!include_from_path.empty())

View File

@ -5,7 +5,9 @@
#include <Poco/Exception.h>
#include <Poco/Util/Application.h>
#include "HierarchyFormatReader.h"
#include <filesystem>
namespace fs = std::filesystem;
bool RegionsHierarchyDataSource::isModified() const
{
@ -27,7 +29,7 @@ RegionsHierarchiesDataProvider::RegionsHierarchiesDataProvider(const std::string
void RegionsHierarchiesDataProvider::discoverFilesWithCustomHierarchies()
{
std::string basename = Poco::Path(path).getBaseName();
std::string basename = fs::path(path).stem();
Poco::Path dir_path = Poco::Path(path).absolute().parent();

View File

@ -2,7 +2,9 @@
#include <IO/ReadBufferFromFile.h>
#include "NamesFormatReader.h"
#include <filesystem>
namespace fs = std::filesystem;
bool LanguageRegionsNamesDataSource::isModified() const
{
@ -11,7 +13,7 @@ bool LanguageRegionsNamesDataSource::isModified() const
size_t LanguageRegionsNamesDataSource::estimateTotalSize() const
{
return Poco::File(path).getSize();
return fs::file_size(path);
}
ILanguageRegionsNamesReaderPtr LanguageRegionsNamesDataSource::createReader()
@ -39,7 +41,7 @@ RegionsNamesDataProvider::RegionsNamesDataProvider(const std::string & directory
ILanguageRegionsNamesDataSourcePtr RegionsNamesDataProvider::getLanguageRegionsNamesSource(const std::string & language) const
{
const auto data_file = getDataFilePath(language);
if (Poco::File(data_file).exists())
if (fs::exists(data_file))
return std::make_unique<LanguageRegionsNamesDataSource>(data_file, language);
else
return {};

View File

@ -12,6 +12,9 @@
#include "DictionaryStructure.h"
#include "registerDictionaries.h"
#include "DictionarySourceHelpers.h"
#include <filesystem>
namespace fs = std::filesystem;
namespace DB
{
@ -80,9 +83,12 @@ std::string FileDictionarySource::toString() const
Poco::Timestamp FileDictionarySource::getLastModification() const
{
return Poco::File{filepath}.getLastModified();
fs::file_time_type fs_time = fs::last_write_time(filepath);
auto micro_sec = std::chrono::duration_cast<std::chrono::microseconds>(fs_time.time_since_epoch());
return Poco::Timestamp(micro_sec.count());
}
void registerDictionarySourceFile(DictionarySourceFactory & factory)
{
auto create_table_source = [=](const DictionaryStructure & dict_struct,

View File

@ -2,7 +2,6 @@
#include <DataStreams/OneBlockInputStream.h>
#include <Interpreters/Context.h>
#include <Poco/File.h>
#include <common/logger_useful.h>
#include <ext/bit_cast.h>
#include <ext/range.h>
@ -13,7 +12,9 @@
#include "registerDictionaries.h"
#include <IO/WriteBufferFromString.h>
#include <IO/WriteHelpers.h>
#include <filesystem>
namespace fs = std::filesystem;
namespace DB
{
@ -49,8 +50,8 @@ LibraryDictionarySource::LibraryDictionarySource(
throw Exception(ErrorCodes::PATH_ACCESS_DENIED, "LibraryDictionarySource: Library path {} is not inside {}", path, dictionaries_lib_path);
}
if (!Poco::File(path).exists())
throw Exception(ErrorCodes::FILE_DOESNT_EXIST, "LibraryDictionarySource: Can't load library {}: file doesn't exist", Poco::File(path).path());
if (!fs::exists(path))
throw Exception(ErrorCodes::FILE_DOESNT_EXIST, "LibraryDictionarySource: Can't load library {}: file doesn't exist", path);
description.init(sample_block);
bridge_helper = std::make_shared<LibraryBridgeHelper>(context, description.sample_block, dictionary_id);