128 static std::once_flag initialized;
129 std::call_once( initialized, [ = ]
131 std::function<qint64(
const QString & )> dirSize;
132 dirSize = [&dirSize](
const QString & dirPath ) -> qint64
137 const QStringList filePaths = dir.entryList( QDir::Files | QDir::System | QDir::Hidden );
138 for (
const QString &filePath : filePaths )
140 QFileInfo fi( dir, filePath );
144 const QStringList childDirPaths = dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot | QDir::System | QDir::Hidden | QDir::NoSymLinks );
145 for (
const QString &childDirPath : childDirPaths )
147 size += dirSize( dirPath + QDir::separator() + childDirPath );
154 QStorageInfo storageInfo( cacheDir );
155 bytesFree = storageInfo.bytesFree() + dirSize( cacheDir );
159 qint64 available10MB = bytesFree / 1024 / ( 1024LL * 10 );
160 qint64 cacheSize10MB = 0;
161 if ( available10MB > 2500 )
168 if ( available10MB > 700 )
171 cacheSize10MB += ( available10MB - 700 ) * 0.025;
174 if ( available10MB > 50 )
177 cacheSize10MB += ( available10MB - 50 ) * 0.075;
181#if defined( Q_OS_ANDROID )
185 cacheSize10MB += std::max( 2LL,
static_cast<qint64
>( available10MB * 0.16 ) );
188 cacheSize10MB += std::max( 5LL,
static_cast<qint64
>( available10MB * 0.30 ) );
191 cacheSize = cacheSize10MB * 10 * 1024 * 1024;