diff --git a/src/scanner/MediaScanner.cpp b/src/scanner/MediaScanner.cpp index 309ed8f0..3f18075f 100644 --- a/src/scanner/MediaScanner.cpp +++ b/src/scanner/MediaScanner.cpp @@ -506,7 +506,7 @@ MediaScanner::scanAudioFile(const std::filesystem::path& file, bool forceScan, S { notifyInProgressIfNeeded(stats); - time_t lastWriteTime {}; + Wt::WDateTime lastWriteTime; try { 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)}; - if (track && track->getLastWriteTime().toTime_t() == lastWriteTime + if (track && track->getLastWriteTime().toTime_t() == lastWriteTime.toTime_t() && track->getScanVersion() == _scanVersion) { stats.skips++; @@ -637,7 +637,7 @@ MediaScanner::scanAudioFile(const std::filesystem::path& file, bool forceScan, S track.modify()->setScanVersion(_scanVersion); track.modify()->setRelease(release); 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()->setDuration(trackInfo->duration); track.modify()->setAddedTime(Wt::WLocalDateTime::currentServerDateTime().toUTC()); diff --git a/src/utils/Path.cpp b/src/utils/Path.cpp index 35d4aa30..dd2c4b21 100644 --- a/src/utils/Path.cpp +++ b/src/utils/Path.cpp @@ -76,7 +76,7 @@ ensureDirectory(const std::filesystem::path& dir) return std::filesystem::create_directory(dir); } -std::time_t +Wt::WDateTime getLastWriteTime(const std::filesystem::path& file) { struct stat sb {}; @@ -84,6 +84,6 @@ getLastWriteTime(const std::filesystem::path& file) if (stat(file.string().c_str(), &sb) == -1) throw LmsException("Failed to get stats on file '" + file.string() + "'" ); - return sb.st_mtime; + return Wt::WDateTime::fromTime_t(sb.st_mtime); } diff --git a/src/utils/Path.hpp b/src/utils/Path.hpp index a0fb5865..f7e82893 100644 --- a/src/utils/Path.hpp +++ b/src/utils/Path.hpp @@ -23,6 +23,8 @@ #include #include +#include + void computeCrc(const std::filesystem::path& p, std::vector& checksum); // Make sure the given path is a directory @@ -30,5 +32,5 @@ void computeCrc(const std::filesystem::path& p, std::vector& chec bool ensureDirectory(const std::filesystem::path& dir); // Get the last write time since Epoch -std::time_t getLastWriteTime(const std::filesystem::path& dir); +Wt::WDateTime getLastWriteTime(const std::filesystem::path& dir);