SqlDatabase: Ask freeSpace for directory, fix for Windows

See owncloud/enterprise#1955
This commit is contained in:
Christian Kamm 2017-04-26 10:12:26 +02:00 committed by ckamm
parent fd40113e48
commit f8c0e796df
2 changed files with 10 additions and 2 deletions

View file

@ -17,6 +17,8 @@
#include <QString>
#include <QDebug>
#include <QFile>
#include <QFileInfo>
#include <QDir>
#include "ownsql.h"
#include "utility.h"
@ -101,8 +103,8 @@ bool SqlDatabase::openOrCreateReadWrite( const QString& filename )
if( !checkDb() ) {
// When disk space is low, checking the db may fail even though it's fine.
qint64 freeSpace = Utility::freeDiskSpace(filename);
if (freeSpace < 1000000) {
qint64 freeSpace = Utility::freeDiskSpace(QFileInfo(filename).dir().absolutePath());
if (freeSpace != -1 && freeSpace < 1000000) {
qDebug() << "Consistency check failed, disk space is low, aborting" << freeSpace;
close();
return false;

View file

@ -43,6 +43,12 @@ namespace Utility
OWNCLOUDSYNC_EXPORT QByteArray userAgentString();
OWNCLOUDSYNC_EXPORT bool hasLaunchOnStartup(const QString &appName);
OWNCLOUDSYNC_EXPORT void setLaunchOnStartup(const QString &appName, const QString& guiName, bool launch);
/**
* Return the amount of free space available.
*
* \a path must point to a directory
*/
OWNCLOUDSYNC_EXPORT qint64 freeDiskSpace(const QString &path);
/**