File tree Expand file tree Collapse file tree 3 files changed +18
-2
lines changed
Expand file tree Collapse file tree 3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change 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' : {
Original file line number Diff line number Diff 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 ()
Original file line number Diff line number Diff 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 )
You can’t perform that action at this time.
0 commit comments