Simplified some path writes
This commit is contained in:
@@ -130,17 +130,17 @@ namespace lms::av
|
|||||||
AudioFile::AudioFile(const std::filesystem::path& p)
|
AudioFile::AudioFile(const std::filesystem::path& p)
|
||||||
: _p{ p }
|
: _p{ p }
|
||||||
{
|
{
|
||||||
int error{ avformat_open_input(&_context, _p.string().c_str(), nullptr, nullptr) };
|
int error{ avformat_open_input(&_context, _p.c_str(), nullptr, nullptr) };
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
LMS_LOG(AV, ERROR, "Cannot open " << _p.string() << ": " << averror_to_string(error));
|
LMS_LOG(AV, ERROR, "Cannot open " << _p << ": " << averror_to_string(error));
|
||||||
throw AudioFileException{ error };
|
throw AudioFileException{ error };
|
||||||
}
|
}
|
||||||
|
|
||||||
error = avformat_find_stream_info(_context, nullptr);
|
error = avformat_find_stream_info(_context, nullptr);
|
||||||
if (error < 0)
|
if (error < 0)
|
||||||
{
|
{
|
||||||
LMS_LOG(AV, ERROR, "Cannot find stream information on " << _p.string() << ": " << averror_to_string(error));
|
LMS_LOG(AV, ERROR, "Cannot find stream information on " << _p << ": " << averror_to_string(error));
|
||||||
avformat_close_input(&_context);
|
avformat_close_input(&_context);
|
||||||
throw AudioFileException{ error };
|
throw AudioFileException{ error };
|
||||||
}
|
}
|
||||||
@@ -353,7 +353,7 @@ namespace lms::av
|
|||||||
{ ".mka", "audio/x-matroska" },
|
{ ".mka", "audio/x-matroska" },
|
||||||
};
|
};
|
||||||
|
|
||||||
auto it{ entries.find(core::stringUtils::stringToLower(fileExtension.string())) };
|
auto it{ entries.find(core::stringUtils::stringToLower(fileExtension.c_str())) };
|
||||||
if (it == std::cend(entries))
|
if (it == std::cend(entries))
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace lms::av::transcoding
|
|||||||
throw Exception{ "File error '" + _inputParameters.trackPath.string() + "': " + e.what() };
|
throw Exception{ "File error '" + _inputParameters.trackPath.string() + "': " + e.what() };
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG(INFO, "Transcoding file '" << _inputParameters.trackPath.string() << "'");
|
LOG(INFO, "Transcoding file " << _inputParameters.trackPath);
|
||||||
|
|
||||||
std::vector<std::string> args;
|
std::vector<std::string> args;
|
||||||
|
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ namespace lms::zip
|
|||||||
{
|
{
|
||||||
assert(_currentEntry != std::cend(_entries));
|
assert(_currentEntry != std::cend(_entries));
|
||||||
|
|
||||||
std::ifstream ifs{ _currentEntry->filePath.c_str(), std::ios_base::binary };
|
std::ifstream ifs{ _currentEntry->filePath, std::ios_base::binary };
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
throw FileException{ _currentEntry->filePath, "cannot open file", errno };
|
throw FileException{ _currentEntry->filePath, "cannot open file", errno };
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace lms::core
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_config.readFile(p.string().c_str());
|
_config.readFile(p.c_str());
|
||||||
}
|
}
|
||||||
catch (libconfig::FileIOException& e)
|
catch (libconfig::FileIOException& e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,13 +39,13 @@ namespace lms
|
|||||||
Wt::Http::ResponseContinuation* FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::Response& response)
|
Wt::Http::ResponseContinuation* FileResourceHandler::processRequest(const Wt::Http::Request& request, Wt::Http::Response& response)
|
||||||
{
|
{
|
||||||
::uint64_t startByte{ _offset };
|
::uint64_t startByte{ _offset };
|
||||||
std::ifstream ifs{ _path.string().c_str(), std::ios::in | std::ios::binary };
|
std::ifstream ifs{ _path, std::ios::in | std::ios::binary };
|
||||||
|
|
||||||
if (startByte == 0)
|
if (startByte == 0)
|
||||||
{
|
{
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
{
|
{
|
||||||
LMS_LOG(UTILS, ERROR, "Cannot open file stream for '" << _path.string() << "'");
|
LMS_LOG(UTILS, ERROR, "Cannot open file stream for " << _path);
|
||||||
response.setStatus(404);
|
response.setStatus(404);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ namespace lms
|
|||||||
const ::uint64_t fileSize{ static_cast<::uint64_t>(ifs.tellg()) };
|
const ::uint64_t fileSize{ static_cast<::uint64_t>(ifs.tellg()) };
|
||||||
ifs.seekg(0, std::ios::beg);
|
ifs.seekg(0, std::ios::beg);
|
||||||
|
|
||||||
LMS_LOG(UTILS, DEBUG, "File '" << _path.string() << "', fileSize = " << fileSize);
|
LMS_LOG(UTILS, DEBUG, "File " << _path << ", fileSize = " << fileSize);
|
||||||
|
|
||||||
response.addHeader("Accept-Ranges", "bytes");
|
response.addHeader("Accept-Ranges", "bytes");
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ namespace lms
|
|||||||
}
|
}
|
||||||
else if (!ifs)
|
else if (!ifs)
|
||||||
{
|
{
|
||||||
LMS_LOG(UTILS, ERROR, "Cannot reopen file stream for '" << _path.string() << "'");
|
LMS_LOG(UTILS, ERROR, "Cannot reopen file stream for " << _path);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace lms::core::pathUtils
|
|||||||
{
|
{
|
||||||
core::Crc32Calculator crc32;
|
core::Crc32Calculator crc32;
|
||||||
|
|
||||||
std::ifstream ifs{ p.string().c_str(), std::ios_base::binary };
|
std::ifstream ifs{ p, std::ios_base::binary };
|
||||||
if (ifs)
|
if (ifs)
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
@@ -51,7 +51,7 @@ namespace lms::core::pathUtils
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Failed to open file '" << p.string() << "'");
|
LMS_LOG(DBUPDATER, ERROR, "Failed to open file " << p);
|
||||||
throw LmsException("Failed to open file '" + p.string() + "'");
|
throw LmsException("Failed to open file '" + p.string() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ namespace lms::core::pathUtils
|
|||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
if (stat(file.string().c_str(), &sb) == -1)
|
if (stat(file.c_str(), &sb) == -1)
|
||||||
throw LmsException("Failed to get stats on file '" + file.string() + "'");
|
throw LmsException("Failed to get stats on file '" + file.string() + "'");
|
||||||
|
|
||||||
return Wt::WDateTime::fromTime_t(sb.st_mtime);
|
return Wt::WDateTime::fromTime_t(sb.st_mtime);
|
||||||
@@ -95,7 +95,7 @@ namespace lms::core::pathUtils
|
|||||||
|
|
||||||
if (std::filesystem::exists(excludePath, ec))
|
if (std::filesystem::exists(excludePath, ec))
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Found '" << excludePath.string() << "': skipping directory");
|
LMS_LOG(DBUPDATER, DEBUG, "Found " << excludePath << ": skipping directory");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,7 +135,7 @@ namespace lms::core::pathUtils
|
|||||||
|
|
||||||
bool hasFileAnyExtension(const std::filesystem::path& file, std::span<const std::filesystem::path> supportedExtensions)
|
bool hasFileAnyExtension(const std::filesystem::path& file, std::span<const std::filesystem::path> supportedExtensions)
|
||||||
{
|
{
|
||||||
const std::filesystem::path extension{ stringUtils::stringToLower(file.extension().string()) };
|
const std::filesystem::path extension{ stringUtils::stringToLower(file.extension().c_str()) };
|
||||||
|
|
||||||
return (std::find(std::cbegin(supportedExtensions), std::cend(supportedExtensions), extension) != std::cend(supportedExtensions));
|
return (std::find(std::cbegin(supportedExtensions), std::cend(supportedExtensions), extension) != std::cend(supportedExtensions));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,9 +72,9 @@ namespace lms::db
|
|||||||
// Session living class handling the database and the login
|
// Session living class handling the database and the login
|
||||||
Db::Db(const std::filesystem::path& dbPath, std::size_t connectionCount)
|
Db::Db(const std::filesystem::path& dbPath, std::size_t connectionCount)
|
||||||
{
|
{
|
||||||
LMS_LOG(DB, INFO, "Creating connection pool on file " << dbPath.string());
|
LMS_LOG(DB, INFO, "Creating connection pool on file " << dbPath);
|
||||||
|
|
||||||
auto connection{ std::make_unique<Connection>(dbPath.string()) };
|
auto connection{ std::make_unique<Connection>(dbPath) };
|
||||||
if (core::IConfig * config{ core::Service<core::IConfig>::get() }) // may not be here on testU
|
if (core::IConfig * config{ core::Service<core::IConfig>::get() }) // may not be here on testU
|
||||||
connection->setProperty("show-queries", config->getBool("db-show-queries", false) ? "true" : "false");
|
connection->setProperty("show-queries", config->getBool("db-show-queries", false) ? "true" : "false");
|
||||||
|
|
||||||
|
|||||||
@@ -89,17 +89,12 @@ namespace lms::db
|
|||||||
if (path.empty())
|
if (path.empty())
|
||||||
return path;
|
return path;
|
||||||
|
|
||||||
// Convert the path to string
|
|
||||||
std::string pathStr{ path.string() };
|
std::string pathStr{ path.string() };
|
||||||
|
|
||||||
// Check if the last character is a directory separator
|
// Check if the last character is a directory separator
|
||||||
if (pathStr.back() != std::filesystem::path::preferred_separator)
|
if (pathStr.back() != std::filesystem::path::preferred_separator)
|
||||||
{
|
|
||||||
// If not, add the preferred separator
|
|
||||||
pathStr += std::filesystem::path::preferred_separator;
|
pathStr += std::filesystem::path::preferred_separator;
|
||||||
}
|
|
||||||
|
|
||||||
// Return the new path
|
|
||||||
return std::filesystem::path{ pathStr };
|
return std::filesystem::path{ pathStr };
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ namespace lms::db
|
|||||||
{
|
{
|
||||||
session.checkReadTransaction();
|
session.checkReadTransaction();
|
||||||
|
|
||||||
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<PlayListFile>>("SELECT pl_f from playlist_file pl_f").where("pl_f.absolute_file_path = ?").bind(p.string()));
|
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<PlayListFile>>("SELECT pl_f from playlist_file pl_f").where("pl_f.absolute_file_path = ?").bind(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayListFile::find(Session& session, PlayListFileId& lastRetrievedId, std::size_t count, const std::function<void(const pointer&)>& func)
|
void PlayListFile::find(Session& session, PlayListFileId& lastRetrievedId, std::size_t count, const std::function<void(const pointer&)>& func)
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ namespace lms::db
|
|||||||
{
|
{
|
||||||
session.checkReadTransaction();
|
session.checkReadTransaction();
|
||||||
|
|
||||||
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<Track>>("SELECT t from track t").where("t.absolute_file_path = ?").bind(p.string()));
|
return utils::fetchQuerySingleResult(session.getDboSession()->query<Wt::Dbo::ptr<Track>>("SELECT t from track t").where("t.absolute_file_path = ?").bind(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
Track::pointer Track::find(Session& session, TrackId id)
|
Track::pointer Track::find(Session& session, TrackId id)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace lms::image
|
|||||||
{
|
{
|
||||||
LMS_SCOPED_TRACE_DETAILED("Image", "ReadFile");
|
LMS_SCOPED_TRACE_DETAILED("Image", "ReadFile");
|
||||||
|
|
||||||
std::ifstream ifs{ p.string(), std::ios::binary };
|
std::ifstream ifs{ p, std::ios::binary };
|
||||||
if (!ifs.is_open())
|
if (!ifs.is_open())
|
||||||
throw Exception{ "Cannot open file '" + p.string() + "' for reading purpose" };
|
throw Exception{ "Cannot open file '" + p.string() + "' for reading purpose" };
|
||||||
|
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace lms::image
|
|||||||
{
|
{
|
||||||
void init(const std::filesystem::path& path)
|
void init(const std::filesystem::path& path)
|
||||||
{
|
{
|
||||||
Magick::InitializeMagick(path.string().c_str());
|
Magick::InitializeMagick(path.c_str());
|
||||||
|
|
||||||
if (auto nbThreads{ MagickLib::GetMagickResourceLimit(MagickLib::ThreadsResource) }; nbThreads != 1)
|
if (auto nbThreads{ MagickLib::GetMagickResourceLimit(MagickLib::ThreadsResource) }; nbThreads != 1)
|
||||||
LMS_LOG(COVER, WARNING, "Consider setting env var OMP_NUM_THREADS=1 to save resources");
|
LMS_LOG(COVER, WARNING, "Consider setting env var OMP_NUM_THREADS=1 to save resources");
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ namespace lms::image::GraphicsMagick
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_image.read(p.string().c_str());
|
_image.read(p.c_str());
|
||||||
}
|
}
|
||||||
catch (Magick::WarningCoder& e)
|
catch (Magick::WarningCoder& e)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -73,9 +73,7 @@ namespace lms::image::STB
|
|||||||
int n{};
|
int n{};
|
||||||
_data = UniquePtrFree{ stbi_load(p.c_str(), &_width, &_height, &n, 3), std::free };
|
_data = UniquePtrFree{ stbi_load(p.c_str(), &_width, &_height, &n, 3), std::free };
|
||||||
if (!_data)
|
if (!_data)
|
||||||
{
|
|
||||||
throw StbiException{ "Cannot load image from file" };
|
throw StbiException{ "Cannot load image from file" };
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawImage::resize(ImageSize width)
|
void RawImage::resize(ImageSize width)
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ namespace lms::metadata
|
|||||||
}
|
}
|
||||||
catch (const Exception& e)
|
catch (const Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(METADATA, ERROR, "File '" << p.string() << "': parsing failed");
|
LMS_LOG(METADATA, ERROR, "File " << p << ": parsing failed");
|
||||||
throw ParseException{};
|
throw ParseException{};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ namespace lms::metadata
|
|||||||
{
|
{
|
||||||
LMS_SCOPED_TRACE_DETAILED("MetaData", "TagLibParseFile");
|
LMS_SCOPED_TRACE_DETAILED("MetaData", "TagLibParseFile");
|
||||||
|
|
||||||
return TagLib::FileRef{ p.string().c_str(), true // read audio properties
|
return TagLib::FileRef{ p.c_str(), true // read audio properties
|
||||||
,
|
,
|
||||||
readStyleToTagLibReadStyle(parserReadStyle) };
|
readStyleToTagLibReadStyle(parserReadStyle) };
|
||||||
}
|
}
|
||||||
@@ -199,13 +199,13 @@ namespace lms::metadata
|
|||||||
{
|
{
|
||||||
if (_file.isNull())
|
if (_file.isNull())
|
||||||
{
|
{
|
||||||
LMS_LOG(METADATA, ERROR, "File '" << p.string() << "': parsing failed");
|
LMS_LOG(METADATA, ERROR, "File " << p << ": parsing failed");
|
||||||
throw ParsingFailedException{};
|
throw ParsingFailedException{};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_file.audioProperties())
|
if (!_file.audioProperties())
|
||||||
{
|
{
|
||||||
LMS_LOG(METADATA, ERROR, "File '" << p.string() << "': no audio properties");
|
LMS_LOG(METADATA, ERROR, "File " << p << ": no audio properties");
|
||||||
throw ParsingFailedException{};
|
throw ParsingFailedException{};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ namespace lms::cover
|
|||||||
{
|
{
|
||||||
setJpegQuality(core::Service<core::IConfig>::get()->getULong("cover-jpeg-quality", 75));
|
setJpegQuality(core::Service<core::IConfig>::get()->getULong("cover-jpeg-quality", 75));
|
||||||
|
|
||||||
LMS_LOG(COVER, INFO, "Default release cover path = '" << defaultReleaseCoverSvgPath.string() << "'");
|
LMS_LOG(COVER, INFO, "Default release cover path = " << defaultReleaseCoverSvgPath);
|
||||||
LMS_LOG(COVER, INFO, "Max cache size = " << _cache.getMaxCacheSize());
|
LMS_LOG(COVER, INFO, "Max cache size = " << _cache.getMaxCacheSize());
|
||||||
|
|
||||||
_defaultReleaseCover = image::readImage(defaultReleaseCoverSvgPath); // may throw
|
_defaultReleaseCover = image::readImage(defaultReleaseCoverSvgPath); // may throw
|
||||||
@@ -141,7 +141,7 @@ namespace lms::cover
|
|||||||
}
|
}
|
||||||
catch (const image::Exception& e)
|
catch (const image::Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(COVER, ERROR, "Cannot read cover in file '" << p.string() << "': " << e.what());
|
LMS_LOG(COVER, ERROR, "Cannot read cover in file " << p << ": " << e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
@@ -183,7 +183,7 @@ namespace lms::cover
|
|||||||
}
|
}
|
||||||
catch (av::Exception& e)
|
catch (av::Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(COVER, ERROR, "Cannot get covers from track " << p.string() << ": " << e.what());
|
LMS_LOG(COVER, ERROR, "Cannot get covers from track " << p << ": " << e.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
return image;
|
return image;
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
catch (const metadata::Exception& e)
|
catch (const metadata::Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, INFO, "Failed to parse audio file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, ERROR, "Failed to parse audio file " << _file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,7 +391,7 @@ namespace lms::scanner
|
|||||||
std::error_code ec;
|
std::error_code ec;
|
||||||
if (!std::filesystem::exists(otherTrack->getAbsoluteFilePath(), ec))
|
if (!std::filesystem::exists(otherTrack->getAbsoluteFilePath(), ec))
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Considering track '" << _file.string() << "' moved from '" << otherTrack->getAbsoluteFilePath() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Considering track " << _file << " moved from " << otherTrack->getAbsoluteFilePath());
|
||||||
track = otherTrack;
|
track = otherTrack;
|
||||||
track.modify()->setAbsoluteFilePath(_file);
|
track.modify()->setAbsoluteFilePath(_file);
|
||||||
}
|
}
|
||||||
@@ -415,7 +415,7 @@ namespace lms::scanner
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Skipped '" << _file.string() << "' (similar MBID in '" << otherTrack->getAbsoluteFilePath().string() << "')");
|
LMS_LOG(DBUPDATER, DEBUG, "Skipped " << _file << " (similar MBID in " << otherTrack->getAbsoluteFilePath() << ")");
|
||||||
// As this MBID already exists, just remove what we just scanned
|
// As this MBID already exists, just remove what we just scanned
|
||||||
if (track)
|
if (track)
|
||||||
{
|
{
|
||||||
@@ -430,7 +430,7 @@ namespace lms::scanner
|
|||||||
// We estimate this is an audio file if the duration is not null
|
// We estimate this is an audio file if the duration is not null
|
||||||
if (_parsedTrack->audioProperties.duration == std::chrono::milliseconds::zero())
|
if (_parsedTrack->audioProperties.duration == std::chrono::milliseconds::zero())
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Skipped '" << _file.string() << "' (duration is 0)");
|
LMS_LOG(DBUPDATER, DEBUG, "Skipped " << _file << " (duration is 0)");
|
||||||
|
|
||||||
// If Track exists here, delete it!
|
// If Track exists here, delete it!
|
||||||
if (track)
|
if (track)
|
||||||
@@ -565,12 +565,12 @@ namespace lms::scanner
|
|||||||
|
|
||||||
if (added)
|
if (added)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Added audio file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Added audio file " << _file);
|
||||||
stats.additions++;
|
stats.additions++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Updated audio file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Updated audio file " << _file);
|
||||||
stats.updates++;
|
stats.updates++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,7 +77,8 @@ namespace lms::scanner
|
|||||||
}
|
}
|
||||||
catch (const image::Exception& e)
|
catch (const image::Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Cannot read image in file '" << _file.c_str() << "': " << e.what());
|
_parsedImageInfo.reset();
|
||||||
|
LMS_LOG(DBUPDATER, ERROR, "Cannot read image in file " << _file << ": " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,6 +102,7 @@ namespace lms::scanner
|
|||||||
{
|
{
|
||||||
image.remove();
|
image.remove();
|
||||||
stats.deletions++;
|
stats.deletions++;
|
||||||
|
LMS_LOG(DBUPDATER, DEBUG, "Removed image " << _file);
|
||||||
}
|
}
|
||||||
context.stats.errors.emplace_back(_file, ScanErrorType::CannotReadImageFile);
|
context.stats.errors.emplace_back(_file, ScanErrorType::CannotReadImageFile);
|
||||||
return;
|
return;
|
||||||
@@ -119,12 +121,12 @@ namespace lms::scanner
|
|||||||
|
|
||||||
if (added)
|
if (added)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Added image '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Added image " << _file);
|
||||||
stats.additions++;
|
stats.additions++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Updated image '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Updated image " << _file);
|
||||||
stats.updates++;
|
stats.updates++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,15 +62,15 @@ namespace lms::scanner
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::ifstream ifs{ _file.string() };
|
std::ifstream ifs{ _file };
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Cannot open file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, ERROR, "Cannot open file " << _file);
|
||||||
else
|
else
|
||||||
_parsedLyrics = metadata::parseLyrics(ifs);
|
_parsedLyrics = metadata::parseLyrics(ifs);
|
||||||
}
|
}
|
||||||
catch (const metadata::Exception& e)
|
catch (const metadata::Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Cannot read lyrics in file '" << _file.string() << "': " << e.what());
|
LMS_LOG(DBUPDATER, ERROR, "Cannot read lyrics in file " << _file << ": " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,12 +122,12 @@ namespace lms::scanner
|
|||||||
|
|
||||||
if (added)
|
if (added)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Added external lyrics '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Added external lyrics " << _file);
|
||||||
stats.additions++;
|
stats.additions++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Updated external lyrics '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Updated external lyrics " << _file);
|
||||||
stats.updates++;
|
stats.updates++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,15 +66,15 @@ namespace lms::scanner
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::ifstream ifs{ _file.string() };
|
std::ifstream ifs{ _file };
|
||||||
if (!ifs)
|
if (!ifs)
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Cannot open file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, ERROR, "Cannot open file " << _file);
|
||||||
else
|
else
|
||||||
_parsedPlayList = metadata::parsePlayList(ifs);
|
_parsedPlayList = metadata::parsePlayList(ifs);
|
||||||
}
|
}
|
||||||
catch (const metadata::Exception& e)
|
catch (const metadata::Exception& e)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Cannot read playlist in file '" << _file.string() << "': " << e.what());
|
LMS_LOG(DBUPDATER, ERROR, "Cannot read playlist in file " << _file << ": " << e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,13 +120,12 @@ namespace lms::scanner
|
|||||||
|
|
||||||
if (added)
|
if (added)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Added playlist file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Added playlist file " << _file);
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "db playlist file = '" << playList->getAbsoluteFilePath().string() << "'");
|
|
||||||
stats.additions++;
|
stats.additions++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, DEBUG, "Updated playlist file '" << _file.string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, "Updated playlist file '" << _file);
|
||||||
stats.updates++;
|
stats.updates++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ namespace lms::scanner
|
|||||||
{
|
{
|
||||||
{
|
{
|
||||||
LMS_SCOPED_TRACE_OVERVIEW("Scanner", operation->getName());
|
LMS_SCOPED_TRACE_OVERVIEW("Scanner", operation->getName());
|
||||||
LMS_LOG(DBUPDATER, DEBUG, operation->getName() << ": scanning file '" << operation->getFile().string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, operation->getName() << ": scanning file " << operation->getFile());
|
||||||
operation->scan();
|
operation->scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace lms::scanner
|
|||||||
{
|
{
|
||||||
[[maybe_unused]] auto [it, inserted]{ _scannerByExtension.emplace(extension, scanner) };
|
[[maybe_unused]] auto [it, inserted]{ _scannerByExtension.emplace(extension, scanner) };
|
||||||
assert(inserted);
|
assert(inserted);
|
||||||
LMS_LOG(DBUPDATER, INFO, "Registered extension '" << extension.string() << "' for '" << scanner->getName() << "'");
|
LMS_LOG(DBUPDATER, INFO, "Registered extension " << extension << " for " << scanner->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,12 +88,12 @@ namespace lms::scanner
|
|||||||
|
|
||||||
if (ec)
|
if (ec)
|
||||||
{
|
{
|
||||||
LMS_LOG(DBUPDATER, ERROR, "Cannot scan file '" << path.string() << "': " << ec.message());
|
LMS_LOG(DBUPDATER, ERROR, "Cannot scan file " << path << ": " << ec.message());
|
||||||
context.stats.errors.emplace_back(ScanError{ path, ScanErrorType::CannotReadFile, ec.message() });
|
context.stats.errors.emplace_back(ScanError{ path, ScanErrorType::CannotReadFile, ec.message() });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto itScanner{ _scannerByExtension.find(core::stringUtils::stringToLower(path.extension().string())) };
|
auto itScanner{ _scannerByExtension.find(core::stringUtils::stringToLower(path.extension().c_str())) };
|
||||||
if (itScanner != std::cend(_scannerByExtension))
|
if (itScanner != std::cend(_scannerByExtension))
|
||||||
{
|
{
|
||||||
IFileScanner& scanner{ *itScanner->second };
|
IFileScanner& scanner{ *itScanner->second };
|
||||||
@@ -140,7 +140,7 @@ namespace lms::scanner
|
|||||||
if (_abortScan)
|
if (_abortScan)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
LMS_LOG(DBUPDATER, DEBUG, scanOperation->getName() << ": processing result for '" << scanOperation->getFile().string() << "'");
|
LMS_LOG(DBUPDATER, DEBUG, scanOperation->getName() << ": processing result for " << scanOperation->getFile());
|
||||||
scanOperation->processResult(context);
|
scanOperation->processResult(context);
|
||||||
context.stats.scans++;
|
context.stats.scans++;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -178,7 +178,7 @@ namespace lms
|
|||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
std::ofstream oss{ wtConfigPath.string().c_str(), std::ios::out };
|
std::ofstream oss{ wtConfigPath, std::ios::out };
|
||||||
if (!oss)
|
if (!oss)
|
||||||
throw core::LmsException{ "Can't open '" + wtConfigPath.string() + "' for writing!" };
|
throw core::LmsException{ "Can't open '" + wtConfigPath.string() + "' for writing!" };
|
||||||
|
|
||||||
|
|||||||
@@ -365,14 +365,14 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
std::cout << "Using Lyrics:" << std::endl;
|
std::cout << "Using Lyrics:" << std::endl;
|
||||||
|
|
||||||
std::ifstream ifs{ file.string() };
|
std::ifstream ifs{ file };
|
||||||
if (ifs)
|
if (ifs)
|
||||||
{
|
{
|
||||||
const metadata::Lyrics lyrics{ metadata::parseLyrics(ifs) };
|
const metadata::Lyrics lyrics{ metadata::parseLyrics(ifs) };
|
||||||
std::cout << lyrics << std::endl;
|
std::cout << lyrics << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
std::cerr << "Cannot open file '" << file.string() << "'";
|
std::cerr << "Cannot open file " << file;
|
||||||
}
|
}
|
||||||
catch (metadata::Exception& e)
|
catch (metadata::Exception& e)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user