Avoid duplicate refresh of Catalogs
- also fix duplicate reporting of successful refresh
This commit is contained in:
parent
945cf5d963
commit
3bfd0c872a
@ -78,7 +78,6 @@ public:
|
|||||||
{
|
{
|
||||||
// refreshing
|
// refreshing
|
||||||
m_owner->changeStatus(Delegate::STATUS_IN_PROGRESS);
|
m_owner->changeStatus(Delegate::STATUS_IN_PROGRESS);
|
||||||
SG_LOG(SG_GENERAL, SG_WARN, "downloading " << aUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@ -177,9 +176,7 @@ CatalogRef Catalog::createFromUrl(Root* aRoot, const std::string& aUrl)
|
|||||||
{
|
{
|
||||||
CatalogRef c = new Catalog(aRoot);
|
CatalogRef c = new Catalog(aRoot);
|
||||||
c->m_url = aUrl;
|
c->m_url = aUrl;
|
||||||
Downloader* dl = new Downloader(c, aUrl);
|
c->refresh();
|
||||||
aRoot->makeHTTPRequest(dl);
|
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,9 +216,12 @@ CatalogRef Catalog::createFromPath(Root* aRoot, const SGPath& aPath)
|
|||||||
|
|
||||||
CatalogRef c = new Catalog(aRoot);
|
CatalogRef c = new Catalog(aRoot);
|
||||||
c->m_installRoot = aPath;
|
c->m_installRoot = aPath;
|
||||||
c->parseProps(props); // will set status
|
c->parseProps(props);
|
||||||
c->parseTimestamp();
|
c->parseTimestamp();
|
||||||
|
|
||||||
|
// parsed XML ok, mark status as valid
|
||||||
|
c->changeStatus(Delegate::STATUS_SUCCESS);
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +300,13 @@ Catalog::installedPackages() const
|
|||||||
|
|
||||||
void Catalog::refresh()
|
void Catalog::refresh()
|
||||||
{
|
{
|
||||||
|
if (m_refreshRequest.valid()) {
|
||||||
|
// refresh in progress
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Downloader* dl = new Downloader(this, url());
|
Downloader* dl = new Downloader(this, url());
|
||||||
|
m_refreshRequest = dl;
|
||||||
// will update status to IN_PROGRESS
|
// will update status to IN_PROGRESS
|
||||||
m_root->makeHTTPRequest(dl);
|
m_root->makeHTTPRequest(dl);
|
||||||
}
|
}
|
||||||
@ -387,9 +393,6 @@ void Catalog::parseProps(const SGPropertyNode* aProps)
|
|||||||
Dir d(m_installRoot);
|
Dir d(m_installRoot);
|
||||||
d.create(0755);
|
d.create(0755);
|
||||||
}
|
}
|
||||||
|
|
||||||
// parsed XML ok, mark status as valid
|
|
||||||
changeStatus(Delegate::STATUS_SUCCESS);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PackageRef Catalog::getPackageById(const std::string& aId) const
|
PackageRef Catalog::getPackageById(const std::string& aId) const
|
||||||
@ -483,8 +486,8 @@ std::string Catalog::getLocalisedString(const SGPropertyNode* aRoot, const char*
|
|||||||
|
|
||||||
void Catalog::refreshComplete(Delegate::StatusCode aReason)
|
void Catalog::refreshComplete(Delegate::StatusCode aReason)
|
||||||
{
|
{
|
||||||
m_root->catalogRefreshStatus(this, aReason);
|
|
||||||
changeStatus(aReason);
|
changeStatus(aReason);
|
||||||
|
m_refreshRequest.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Catalog::changeStatus(Delegate::StatusCode newStatus)
|
void Catalog::changeStatus(Delegate::StatusCode newStatus)
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <simgear/structure/SGReferenced.hxx>
|
#include <simgear/structure/SGReferenced.hxx>
|
||||||
#include <simgear/structure/SGSharedPtr.hxx>
|
#include <simgear/structure/SGSharedPtr.hxx>
|
||||||
#include <simgear/structure/function_list.hxx>
|
#include <simgear/structure/function_list.hxx>
|
||||||
|
#include <simgear/io/HTTPRequest.hxx>
|
||||||
|
|
||||||
#include <simgear/package/Delegate.hxx>
|
#include <simgear/package/Delegate.hxx>
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ private:
|
|||||||
SGPath m_installRoot;
|
SGPath m_installRoot;
|
||||||
std::string m_url;
|
std::string m_url;
|
||||||
Delegate::StatusCode m_status;
|
Delegate::StatusCode m_status;
|
||||||
|
HTTP::Request_ptr m_refreshRequest;
|
||||||
|
|
||||||
PackageList m_packages;
|
PackageList m_packages;
|
||||||
time_t m_retrievedTime;
|
time_t m_retrievedTime;
|
||||||
|
@ -111,7 +111,6 @@ public:
|
|||||||
Delegate::StatusCode status, const std::string& bytes)
|
Delegate::StatusCode status, const std::string& bytes)
|
||||||
{
|
{
|
||||||
std::string u(request->url());
|
std::string u(request->url());
|
||||||
SG_LOG(SG_IO, SG_INFO, "downloaded thumbnail:" << u);
|
|
||||||
if (status == Delegate::STATUS_SUCCESS) {
|
if (status == Delegate::STATUS_SUCCESS) {
|
||||||
thumbnailCache[u] = bytes;
|
thumbnailCache[u] = bytes;
|
||||||
fireDataForThumbnail(u, bytes);
|
fireDataForThumbnail(u, bytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user