Removed implicit conversion from std::filesystem::file_time_type since it is broken in GCC9, fixes #7
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace MetaData
|
namespace MetaData
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
#include "database/Release.hpp"
|
#include "database/Release.hpp"
|
||||||
#include "database/ScanSettings.hpp"
|
#include "database/ScanSettings.hpp"
|
||||||
#include "database/Track.hpp"
|
#include "database/Track.hpp"
|
||||||
|
#include "utils/Exception.hpp"
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
#include "utils/Path.hpp"
|
#include "utils/Path.hpp"
|
||||||
#include "utils/Utils.hpp"
|
#include "utils/Utils.hpp"
|
||||||
@@ -505,7 +506,17 @@ MediaScanner::scanAudioFile(const std::filesystem::path& file, bool forceScan, S
|
|||||||
{
|
{
|
||||||
notifyInProgressIfNeeded(stats);
|
notifyInProgressIfNeeded(stats);
|
||||||
|
|
||||||
const Wt::WDateTime lastWriteTime {std::filesystem::last_write_time(file)};
|
time_t lastWriteTime {};
|
||||||
|
try
|
||||||
|
{
|
||||||
|
lastWriteTime = getLastWriteTime(file);
|
||||||
|
}
|
||||||
|
catch (LmsException& e)
|
||||||
|
{
|
||||||
|
LMS_LOG(DBUPDATER, ERROR) << e.what();
|
||||||
|
stats.skips++;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!forceScan)
|
if (!forceScan)
|
||||||
{
|
{
|
||||||
@@ -514,7 +525,7 @@ MediaScanner::scanAudioFile(const std::filesystem::path& file, bool forceScan, S
|
|||||||
|
|
||||||
const Track::pointer track {Track::getByPath(*_dbSession, file)};
|
const Track::pointer track {Track::getByPath(*_dbSession, file)};
|
||||||
|
|
||||||
if (track && track->getLastWriteTime().toTime_t() == lastWriteTime.toTime_t()
|
if (track && track->getLastWriteTime().toTime_t() == lastWriteTime
|
||||||
&& track->getScanVersion() == _scanVersion)
|
&& track->getScanVersion() == _scanVersion)
|
||||||
{
|
{
|
||||||
stats.skips++;
|
stats.skips++;
|
||||||
@@ -626,7 +637,7 @@ MediaScanner::scanAudioFile(const std::filesystem::path& file, bool forceScan, S
|
|||||||
track.modify()->setScanVersion(_scanVersion);
|
track.modify()->setScanVersion(_scanVersion);
|
||||||
track.modify()->setRelease(release);
|
track.modify()->setRelease(release);
|
||||||
track.modify()->setClusters(clusters);
|
track.modify()->setClusters(clusters);
|
||||||
track.modify()->setLastWriteTime(lastWriteTime);
|
track.modify()->setLastWriteTime(Wt::WDateTime {std::chrono::system_clock::from_time_t(lastWriteTime)});
|
||||||
track.modify()->setName(title);
|
track.modify()->setName(title);
|
||||||
track.modify()->setDuration(trackInfo->duration);
|
track.modify()->setDuration(trackInfo->duration);
|
||||||
track.modify()->setAddedTime(Wt::WLocalDateTime::currentServerDateTime().toUTC());
|
track.modify()->setAddedTime(Wt::WLocalDateTime::currentServerDateTime().toUTC());
|
||||||
|
|||||||
+19
-2
@@ -19,6 +19,10 @@
|
|||||||
|
|
||||||
#include "Path.hpp"
|
#include "Path.hpp"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@@ -28,7 +32,8 @@
|
|||||||
#include "utils/Exception.hpp"
|
#include "utils/Exception.hpp"
|
||||||
#include "utils/Logger.hpp"
|
#include "utils/Logger.hpp"
|
||||||
|
|
||||||
void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& crc)
|
void
|
||||||
|
computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& crc)
|
||||||
{
|
{
|
||||||
using crc_type = boost::crc_32_type;
|
using crc_type = boost::crc_32_type;
|
||||||
crc_type result;
|
crc_type result;
|
||||||
@@ -62,7 +67,8 @@ void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& crc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ensureDirectory(const std::filesystem::path& dir)
|
bool
|
||||||
|
ensureDirectory(const std::filesystem::path& dir)
|
||||||
{
|
{
|
||||||
if (std::filesystem::exists(dir))
|
if (std::filesystem::exists(dir))
|
||||||
return std::filesystem::is_directory(dir);
|
return std::filesystem::is_directory(dir);
|
||||||
@@ -70,3 +76,14 @@ bool ensureDirectory(const std::filesystem::path& dir)
|
|||||||
return std::filesystem::create_directory(dir);
|
return std::filesystem::create_directory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::time_t
|
||||||
|
getLastWriteTime(const std::filesystem::path& file)
|
||||||
|
{
|
||||||
|
struct stat sb {};
|
||||||
|
|
||||||
|
if (stat(file.string().c_str(), &sb) == -1)
|
||||||
|
throw LmsException("Failed to get stats on file '" + file.string() + "'" );
|
||||||
|
|
||||||
|
return sb.st_mtime;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,3 +29,6 @@ void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& chec
|
|||||||
// Create it if needed
|
// Create it if needed
|
||||||
bool ensureDirectory(const std::filesystem::path& dir);
|
bool ensureDirectory(const std::filesystem::path& dir);
|
||||||
|
|
||||||
|
// Get the last write time since Epoch
|
||||||
|
std::time_t getLastWriteTime(const std::filesystem::path& dir);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user