BUGFIX: Free disk space calculation now works if destination folder does n

ot exist
This commit is contained in:
Christophe Dumez
2010-06-22 11:55:18 +00:00
parent 1197c544aa
commit b8f30381c9
2 changed files with 8 additions and 1 deletions

View File

@@ -5,6 +5,7 @@
- BUGFIX: Fix minor issues in torrent creation tool - BUGFIX: Fix minor issues in torrent creation tool
- BUGFIX: Use checkable actions to avoid issues on systems hiding menu icons (e.g. recent Gnome) - BUGFIX: Use checkable actions to avoid issues on systems hiding menu icons (e.g. recent Gnome)
- BUGFIX: Use busy cursor for search plugin updates - BUGFIX: Use busy cursor for search plugin updates
- BUGFIX: Free disk space calculation now works if destination folder does not exist
- COSMETIC: Display "Alternative speed limits" button as pressed when enabled - COSMETIC: Display "Alternative speed limits" button as pressed when enabled
* Sun Jun 13 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.9 * Sun Jun 13 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.2.9

View File

@@ -134,9 +134,15 @@ QString misc::QDesktopServicesCacheLocation() {
long long misc::freeDiskSpaceOnPath(QString path) { long long misc::freeDiskSpaceOnPath(QString path) {
if(path.isEmpty()) return -1; if(path.isEmpty()) return -1;
path = path.replace("\\", "/");
QDir dir_path(path); QDir dir_path(path);
if(!dir_path.exists()) { if(!dir_path.exists()) {
if(!dir_path.cdUp()) return -1; QStringList parts = path.split("/");
while (parts.size() > 1 && !QDir(parts.join("/")).exists()) {
parts.removeLast();
}
dir_path = QDir(parts.join("/"));
if(!dir_path.exists()) return -1;
} }
Q_ASSERT(dir_path.exists()); Q_ASSERT(dir_path.exists());
#ifndef Q_WS_WIN #ifndef Q_WS_WIN