forked from organicmaps/organicmaps
[index] Check for “pending ready” files every time the app starts.
This commit is contained in:
parent
d0db092dd4
commit
07d95abd47
4 changed files with 40 additions and 14 deletions
|
@ -99,6 +99,27 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
int Index::AddMap(string const & fileName, m2::RectD & rect)
|
||||
{
|
||||
if (GetPlatform().IsFileExistsByFullPath(GetFullPath(fileName + READY_FILE_EXTENSION)))
|
||||
{
|
||||
int const ret = UpdateMap(fileName, rect);
|
||||
switch (ret)
|
||||
{
|
||||
case -1:
|
||||
return -1;
|
||||
case -2:
|
||||
// Not dangerous, but it's strange when adding existing maps.
|
||||
ASSERT(false, ());
|
||||
return feature::DataHeader::v3;
|
||||
default:
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
else
|
||||
return Add(fileName, rect);
|
||||
}
|
||||
|
||||
bool Index::DeleteMap(string const & fileName)
|
||||
{
|
||||
threads::MutexGuard mutexGuard(m_lock);
|
||||
|
@ -111,7 +132,7 @@ bool Index::DeleteMap(string const & fileName)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Index::UpdateMap(string const & fileName, m2::RectD & rect)
|
||||
int Index::UpdateMap(string const & fileName, m2::RectD & rect)
|
||||
{
|
||||
threads::MutexGuard mutexGuard(m_lock);
|
||||
UNUSED_VALUE(mutexGuard);
|
||||
|
@ -120,13 +141,11 @@ bool Index::UpdateMap(string const & fileName, m2::RectD & rect)
|
|||
if (id != INVALID_MWM_ID)
|
||||
{
|
||||
m_info[id].m_status = MwmInfo::STATUS_UPDATE;
|
||||
return false;
|
||||
return -2;
|
||||
}
|
||||
|
||||
ReplaceFileWithReady(fileName);
|
||||
|
||||
(void)AddImpl(fileName, rect);
|
||||
return true;
|
||||
return AddImpl(fileName, rect);
|
||||
}
|
||||
|
||||
void Index::UpdateMwmInfo(MwmId id)
|
||||
|
|
|
@ -33,7 +33,7 @@ public:
|
|||
class Index : public MwmSet
|
||||
{
|
||||
protected:
|
||||
/// @return mwm format version
|
||||
/// @return mwm format version or -1 if file isn't suitable (greater version).
|
||||
virtual int GetInfo(string const & name, MwmInfo & info) const;
|
||||
virtual MwmValue * CreateValue(string const & name) const;
|
||||
virtual void UpdateMwmInfo(MwmId id);
|
||||
|
@ -59,8 +59,13 @@ public:
|
|||
string GetFileName() const;
|
||||
};
|
||||
|
||||
/// @return mwm format version or -1 if file isn't suitable (greater version).
|
||||
int AddMap(string const & fileName, m2::RectD & rect);
|
||||
/// @return mwm format version or
|
||||
/// -1 if file isn't suitable (greater version).
|
||||
/// -2 if file is busy now (delayed update).
|
||||
int UpdateMap(string const & fileName, m2::RectD & rect);
|
||||
bool DeleteMap(string const & fileName);
|
||||
bool UpdateMap(string const & fileName, m2::RectD & rect);
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
@ -70,22 +70,24 @@ public:
|
|||
MwmValueBase * m_pValue;
|
||||
};
|
||||
|
||||
/// Add new mwm. Returns false, if mwm with given fileName already exists.
|
||||
/// Add new map.
|
||||
/// @param[in] fileName File name (without full path) of country.
|
||||
/// @param[out] rect Limit rect of country.
|
||||
/// @return Map format version or -1 if not added
|
||||
/// @return Map format version or -1 if not added (already exists).
|
||||
//@{
|
||||
protected:
|
||||
int AddImpl(string const & fileName, m2::RectD & rect);
|
||||
|
||||
public:
|
||||
int Add(string const & fileName, m2::RectD & rect);
|
||||
inline bool Add(string const & fileName)
|
||||
//@}
|
||||
|
||||
/// Used in unit tests only.
|
||||
inline void Add(string const & fileName)
|
||||
{
|
||||
m2::RectD dummy;
|
||||
return (-1 != Add(fileName, dummy));
|
||||
CHECK(Add(fileName, dummy), ());
|
||||
}
|
||||
//@}
|
||||
|
||||
/// @name Remove mwm.
|
||||
//@{
|
||||
|
|
|
@ -39,7 +39,7 @@ int FeaturesFetcher::AddMap(string const & file)
|
|||
try
|
||||
{
|
||||
m2::RectD r;
|
||||
version = m_multiIndex.Add(file, r);
|
||||
version = m_multiIndex.AddMap(file, r);
|
||||
|
||||
if (version != -1)
|
||||
m_rect.Add(r);
|
||||
|
@ -66,7 +66,7 @@ bool FeaturesFetcher::DeleteMap(string const & file)
|
|||
|
||||
bool FeaturesFetcher::UpdateMap(string const & file, m2::RectD & rect)
|
||||
{
|
||||
return m_multiIndex.UpdateMap(file, rect);
|
||||
return (m_multiIndex.UpdateMap(file, rect) >= 0);
|
||||
}
|
||||
|
||||
void FeaturesFetcher::RemoveAll()
|
||||
|
|
Loading…
Add table
Reference in a new issue