mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2026-01-27 10:23:12 +00:00
Changing version to 2.0.0
This commit is contained in:
@@ -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 ) {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 +
|
||||
|
||||
Reference in New Issue
Block a user