Don't default all directories to DownloadPath if empty

This commit is contained in:
Florian Bruhin 2014-08-05 18:02:12 +02:00
parent f40099e220
commit 11f1c8f369
2 changed files with 6 additions and 3 deletions

View File

@ -24,7 +24,7 @@ import os.path
from functools import partial from functools import partial
from collections import deque from collections import deque
from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject, QTimer from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject, QTimer, QStandardPaths
from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply from PyQt5.QtNetwork import QNetworkRequest, QNetworkReply
import qutebrowser.config.config as config import qutebrowser.config.config as config
@ -211,6 +211,9 @@ class DownloadItem(QObject):
target = os.path.expanduser(filename) target = os.path.expanduser(filename)
else: else:
download_dir = config.get('storage', 'download-directory') download_dir = config.get('storage', 'download-directory')
if download_dir is None:
download_dir = get_standard_dir(
QStandardPaths.DownloadLocation)
target = os.path.join(download_dir, filename) target = os.path.join(download_dir, filename)
logger.debug("Setting filename to {}".format(filename)) logger.debug("Setting filename to {}".format(filename))
if self.filename is not None: if self.filename is not None:

View File

@ -24,7 +24,7 @@ import shlex
import os.path import os.path
from sre_constants import error as RegexError from sre_constants import error as RegexError
from PyQt5.QtCore import QUrl, QStandardPaths from PyQt5.QtCore import QUrl
from PyQt5.QtGui import QColor, QFont from PyQt5.QtGui import QColor, QFont
from PyQt5.QtNetwork import QNetworkProxy from PyQt5.QtNetwork import QNetworkProxy
@ -800,7 +800,7 @@ class Directory(BaseType):
def transform(self, value): def transform(self, value):
if not value: if not value:
return get_standard_dir(QStandardPaths.DownloadLocation) return None
return os.path.expanduser(value) return os.path.expanduser(value)