Changing version to 2.0.0

This commit is contained in:
stephb9959
2021-07-28 23:04:35 -07:00
parent ba239ce323
commit 9352ddab76
3 changed files with 10 additions and 8 deletions

View File

@@ -16,17 +16,19 @@ namespace uCentral {
void LatestFirmwareCache::Stop() {
}
void LatestFirmwareCache::AddToCache(const std::string & DeviceType, const std::string &Revision, const std::string &Id, uint64_t TimeStamp) {
bool LatestFirmwareCache::AddToCache(const std::string & DeviceType, const std::string &Revision, const std::string &Id, uint64_t TimeStamp) {
SubMutexGuard G(Mutex_);
RevisionSet_.insert(Revision);
DeviceSet_.insert(DeviceType);
auto E = Cache_.find(DeviceType);
if((E==Cache_.end()) || (TimeStamp > E->second.TimeStamp)) {
Cache_[DeviceType] = LatestFirmwareCacheEntry{.Id=Id,
if((E==Cache_.end()) || (TimeStamp >= E->second.TimeStamp)) {
Cache_[DeviceType] = LatestFirmwareCacheEntry{ .Id=Id,
.TimeStamp=TimeStamp,
.Revision=Revision};
return true;
}
return false;
}
bool LatestFirmwareCache::FindLatestFirmware(const std::string &DeviceType, LatestFirmwareCacheEntry &Entry ) {

View File

@@ -33,7 +33,7 @@ namespace uCentral {
int Start() override;
void Stop() override;
void AddToCache(const std::string & DeviceType, const std::string & Revision, const std::string &Id, uint64_t TimeStamp);
bool AddToCache(const std::string & DeviceType, const std::string & Revision, const std::string &Id, uint64_t TimeStamp);
// void AddRevision(const std::string &Revision);
bool FindLatestFirmware(const std::string &DeviceType, LatestFirmwareCacheEntry &Entry );
void DumpCache();

View File

@@ -63,17 +63,17 @@ namespace uCentral {
// find the older software and change to latest = 0
F.id = Daemon()->CreateUUID();
if(F.latest)
{
if(LatestFirmwareCache()->AddToCache(F.deviceType,F.revision,F.id,F.imageDate)) {
F.latest = true ;
Poco::Data::Statement Update(Sess);
std::string st{"UPDATE " + DBNAME_FIRMWARES + " SET latest=0 WHERE deviceType=? AND Latest=1"};
Update << ConvertParams(st),
Poco::Data::Keywords::use(F.deviceType);
Update.execute();
} else {
F.latest = false;
}
LatestFirmwareCache()->AddToCache(F.deviceType,F.revision,F.id,F.imageDate);
auto Notes = RESTAPI_utils::to_string(F.notes);
std::string st{"INSERT INTO " + DBNAME_FIRMWARES + " (" +
DBFIELDS_FIRMWARES_SELECT +