forked from organicmaps/organicmaps
[new downloader][MAPSME-121] Add function to check enough space for migrate
This commit is contained in:
parent
796a53ed97
commit
40711bdd07
4 changed files with 20 additions and 0 deletions
|
@ -234,6 +234,12 @@ void Framework::StopLocationFollow()
|
|||
CallDrapeFunction(bind(&df::DrapeEngine::StopLocationFollow, _1));
|
||||
}
|
||||
|
||||
bool Framework::IsEnoughSpaceForMigrate() const
|
||||
{
|
||||
uint64_t const kSpaceSize = 100 /*Mb*/ * 1024 * 1024;
|
||||
return GetPlatform().GetWritableStorageStatus(kSpaceSize) == Platform::TStorageStatus::STORAGE_OK;
|
||||
}
|
||||
|
||||
void Framework::PreMigrate(ms::LatLon const & position,
|
||||
storage::Storage::TChangeCountryFunction const & change,
|
||||
storage::Storage::TProgressFunction const & progress)
|
||||
|
|
|
@ -143,6 +143,7 @@ public:
|
|||
virtual ~Framework();
|
||||
|
||||
/// Migrate to new version of very different data.
|
||||
bool IsEnoughSpaceForMigrate() const;
|
||||
void PreMigrate(ms::LatLon const & position, storage::Storage::TChangeCountryFunction const & change,
|
||||
storage::Storage::TProgressFunction const & progress);
|
||||
void Migrate();
|
||||
|
|
|
@ -168,6 +168,7 @@ public:
|
|||
NOT_ENOUGH_SPACE
|
||||
};
|
||||
TStorageStatus GetWritableStorageStatus(uint64_t neededSize) const;
|
||||
uint64_t GetWritableStorageSpace() const;
|
||||
|
||||
/// @name Functions for concurrent tasks.
|
||||
//@{
|
||||
|
|
|
@ -199,6 +199,18 @@ Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize)
|
|||
return STORAGE_OK;
|
||||
}
|
||||
|
||||
uint64_t Platform::GetWritableStorageSpace() const
|
||||
{
|
||||
struct statfs st;
|
||||
int const ret = statfs(m_writableDir.c_str(), &st);
|
||||
|
||||
LOG(LDEBUG, ("statfs return = ", ret,
|
||||
"; block size = ", st.f_bsize,
|
||||
"; blocks available = ", st.f_bavail));
|
||||
|
||||
return (ret != 0) ? 0 : st.f_bsize * st.f_bavail;
|
||||
}
|
||||
|
||||
namespace pl
|
||||
{
|
||||
void EnumerateFilesByRegExp(string const & directory, string const & regexp,
|
||||
|
|
Loading…
Add table
Reference in a new issue