mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
[fix] fix FindThumbnailPath()
This commit is contained in:
@@ -225,24 +225,17 @@ std::vector<std::filesystem::path> Thumbnail::FindThumbnailPath(
|
|||||||
return thumbnails_path;
|
return thumbnails_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
thumbnails_sorted_by_write_time_.clear();
|
|
||||||
|
|
||||||
for (const auto& entry : std::filesystem::directory_iterator(directory)) {
|
for (const auto& entry : std::filesystem::directory_iterator(directory)) {
|
||||||
if (entry.is_regular_file()) {
|
if (entry.is_regular_file()) {
|
||||||
std::time_t last_write_time = std::chrono::system_clock::to_time_t(
|
thumbnails_path.push_back(entry.path());
|
||||||
time_point_cast<std::chrono::system_clock::duration>(
|
|
||||||
entry.last_write_time() -
|
|
||||||
std::filesystem::file_time_type::clock::now() +
|
|
||||||
std::chrono::system_clock::now()));
|
|
||||||
|
|
||||||
thumbnails_sorted_by_write_time_[last_write_time] = entry.path();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = thumbnails_sorted_by_write_time_.rbegin();
|
std::sort(thumbnails_path.begin(), thumbnails_path.end(),
|
||||||
it != thumbnails_sorted_by_write_time_.rend(); ++it) {
|
[](const std::filesystem::path& a, const std::filesystem::path& b) {
|
||||||
thumbnails_path.push_back(it->second);
|
return std::filesystem::last_write_time(a) >
|
||||||
}
|
std::filesystem::last_write_time(b);
|
||||||
|
});
|
||||||
|
|
||||||
return thumbnails_path;
|
return thumbnails_path;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ class Thumbnail {
|
|||||||
int thumbnail_height_ = 90;
|
int thumbnail_height_ = 90;
|
||||||
char* rgba_buffer_ = nullptr;
|
char* rgba_buffer_ = nullptr;
|
||||||
std::string image_path_ = "thumbnails/";
|
std::string image_path_ = "thumbnails/";
|
||||||
std::map<std::time_t, std::filesystem::path> thumbnails_sorted_by_write_time_;
|
|
||||||
|
|
||||||
unsigned char aes128_key_[16];
|
unsigned char aes128_key_[16];
|
||||||
unsigned char aes128_iv_[16];
|
unsigned char aes128_iv_[16];
|
||||||
|
|||||||
Reference in New Issue
Block a user