129 static std::once_flag initialized;
130 std::call_once( initialized, [ = ]
132 std::function<qint64(
const QString & )> dirSize;
133 dirSize = [&dirSize](
const QString & dirPath ) -> qint64
138 const QStringList filePaths = dir.entryList( QDir::Files | QDir::System | QDir::Hidden );
139 for (
const QString &filePath : filePaths )
141 QFileInfo fi( dir, filePath );
145 const QStringList childDirPaths = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::NoSymLinks );
146 for (
const QString &childDirPath : childDirPaths )
148 size += dirSize( dirPath + QDir::separator() + childDirPath );
155 QStorageInfo storageInfo( cacheDir );
156 bytesFree = storageInfo.bytesFree() + dirSize( cacheDir );
160 qint64 available10MB = bytesFree / 1024 / ( 1024LL * 10 );
161 qint64 cacheSize10MB = 0;
162 if ( available10MB > 2500 )
169 if ( available10MB > 700 )
172 cacheSize10MB += ( available10MB - 700 ) * 0.025;
175 if ( available10MB > 50 )
178 cacheSize10MB += ( available10MB - 50 ) * 0.075;
182#if defined( Q_OS_ANDROID )
186 cacheSize10MB += std::max( 2LL,
static_cast<qint64
>( available10MB * 0.16 ) );
189 cacheSize10MB += std::max( 5LL,
static_cast<qint64
>( available10MB * 0.30 ) );
192 cacheSize = cacheSize10MB * 10 * 1024 * 1024;