mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Free disk space calculation also works if the destination path does not exist
This commit is contained in:
parent
0da83694e0
commit
0d85d0a777
1 changed files with 7 additions and 1 deletions
|
@ -134,9 +134,15 @@ QString misc::QDesktopServicesCacheLocation() {
|
|||
|
||||
long long misc::freeDiskSpaceOnPath(QString path) {
|
||||
if(path.isEmpty()) return -1;
|
||||
path = path.replace("\\", "/");
|
||||
QDir dir_path(path);
|
||||
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());
|
||||
#ifndef Q_WS_WIN
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue