Minor cleanup
This commit is contained in:
@@ -506,7 +506,7 @@ MediaScanner::scanAudioFile(const std::filesystem::path& file, bool forceScan, S
|
|||||||
{
|
{
|
||||||
notifyInProgressIfNeeded(stats);
|
notifyInProgressIfNeeded(stats);
|
||||||
|
|
||||||
time_t lastWriteTime {};
|
Wt::WDateTime lastWriteTime;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lastWriteTime = getLastWriteTime(file);
|
lastWriteTime = getLastWriteTime(file);
|
||||||
@@ -525,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
|
if (track && track->getLastWriteTime().toTime_t() == lastWriteTime.toTime_t()
|
||||||
&& track->getScanVersion() == _scanVersion)
|
&& track->getScanVersion() == _scanVersion)
|
||||||
{
|
{
|
||||||
stats.skips++;
|
stats.skips++;
|
||||||
@@ -637,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(Wt::WDateTime {std::chrono::system_clock::from_time_t(lastWriteTime)});
|
track.modify()->setLastWriteTime(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());
|
||||||
|
|||||||
+2
-2
@@ -76,7 +76,7 @@ ensureDirectory(const std::filesystem::path& dir)
|
|||||||
return std::filesystem::create_directory(dir);
|
return std::filesystem::create_directory(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::time_t
|
Wt::WDateTime
|
||||||
getLastWriteTime(const std::filesystem::path& file)
|
getLastWriteTime(const std::filesystem::path& file)
|
||||||
{
|
{
|
||||||
struct stat sb {};
|
struct stat sb {};
|
||||||
@@ -84,6 +84,6 @@ getLastWriteTime(const std::filesystem::path& file)
|
|||||||
if (stat(file.string().c_str(), &sb) == -1)
|
if (stat(file.string().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 sb.st_mtime;
|
return Wt::WDateTime::fromTime_t(sb.st_mtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -23,6 +23,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <Wt/WDateTime.h>
|
||||||
|
|
||||||
void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& checksum);
|
void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& checksum);
|
||||||
|
|
||||||
// Make sure the given path is a directory
|
// Make sure the given path is a directory
|
||||||
@@ -30,5 +32,5 @@ void computeCrc(const std::filesystem::path& p, std::vector<unsigned char>& chec
|
|||||||
bool ensureDirectory(const std::filesystem::path& dir);
|
bool ensureDirectory(const std::filesystem::path& dir);
|
||||||
|
|
||||||
// Get the last write time since Epoch
|
// Get the last write time since Epoch
|
||||||
std::time_t getLastWriteTime(const std::filesystem::path& dir);
|
Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user