Skip to content

Commit 68f758c

Browse files
Merge pull request #56 from Keeper-of-the-Keys/settings-downloads
Settings downloads
2 parents 54e2da5 + d05e4ca commit 68f758c

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/gpodder/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,10 @@
6464
'retries': 3, # number of retries when downloads time out
6565
},
6666

67+
'fs': {
68+
'downloads': ''
69+
},
70+
6771
'ui': {
6872
# Settings for the Command-Line Interface
6973
'cli': {

src/gpodder/core.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,24 @@ def __init__(self,
6666
# Downloads go to <data_home> or $GPODDER_DOWNLOAD_DIR
6767
self.downloads = os.environ.get('GPODDER_DOWNLOAD_DIR', os.path.join(self.data_home))
6868

69+
# Read config and change default directories where needed
70+
self.config = config_class(config_file)
71+
72+
if self.config.fs.downloads != '':
73+
self.downloads = self.config.fs.downloads
74+
6975
# Initialize the gPodder home directories
7076
util.make_directory(self.data_home)
7177
util.make_directory(self.config_home)
7278

79+
if self.data_home != self.downloads:
80+
if not util.make_directory(self.downloads):
81+
self.logger.warn('Custom downloads path [%s] not writable reverting to default', self.downloads)
82+
self.downloads = os.environ.get('GPODDER_DOWNLOAD_DIR', os.path.join(self.data_home))
83+
7384
# Open the database and configuration file
7485
self.db = database_class(database_file, verbose)
7586
self.model = model_class(self)
76-
self.config = config_class(config_file)
7787

7888
# Load installed/configured plugins
7989
self._load_plugins()

src/gpodder/util.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,11 @@ def make_directory(path):
128128
Tries to create a directory if it does not exist already.
129129
Returns True if the directory exists after the function
130130
call, False otherwise.
131+
If the directory already exists it returns True if it is
132+
writable.
131133
"""
132134
if os.path.isdir(path):
133-
return True
135+
return os.access(path, os.W_OK)
134136

135137
try:
136138
os.makedirs(path)

0 commit comments

Comments
 (0)