Skip to content

Commit

Permalink
Merge pull request #56 from Keeper-of-the-Keys/settings-downloads
Browse files Browse the repository at this point in the history
Settings downloads
  • Loading branch information
Keeper-of-the-Keys authored May 21, 2024
2 parents 54e2da5 + d05e4ca commit 68f758c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/gpodder/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
'retries': 3, # number of retries when downloads time out
},

'fs': {
'downloads': ''
},

'ui': {
# Settings for the Command-Line Interface
'cli': {
Expand Down
12 changes: 11 additions & 1 deletion src/gpodder/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,24 @@ def __init__(self,
# Downloads go to <data_home> or $GPODDER_DOWNLOAD_DIR
self.downloads = os.environ.get('GPODDER_DOWNLOAD_DIR', os.path.join(self.data_home))

# Read config and change default directories where needed
self.config = config_class(config_file)

if self.config.fs.downloads != '':
self.downloads = self.config.fs.downloads

# Initialize the gPodder home directories
util.make_directory(self.data_home)
util.make_directory(self.config_home)

if self.data_home != self.downloads:
if not util.make_directory(self.downloads):
self.logger.warn('Custom downloads path [%s] not writable reverting to default', self.downloads)
self.downloads = os.environ.get('GPODDER_DOWNLOAD_DIR', os.path.join(self.data_home))

# Open the database and configuration file
self.db = database_class(database_file, verbose)
self.model = model_class(self)
self.config = config_class(config_file)

# Load installed/configured plugins
self._load_plugins()
Expand Down
4 changes: 3 additions & 1 deletion src/gpodder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ def make_directory(path):
Tries to create a directory if it does not exist already.
Returns True if the directory exists after the function
call, False otherwise.
If the directory already exists it returns True if it is
writable.
"""
if os.path.isdir(path):
return True
return os.access(path, os.W_OK)

try:
os.makedirs(path)
Expand Down

0 comments on commit 68f758c

Please sign in to comment.