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 64
64
'retries' : 3 , # number of retries when downloads time out
65
65
},
66
66
67
+ 'fs' : {
68
+ 'downloads' : ''
69
+ },
70
+
67
71
'ui' : {
68
72
# Settings for the Command-Line Interface
69
73
'cli' : {
Original file line number Diff line number Diff line change @@ -66,14 +66,24 @@ def __init__(self,
66
66
# Downloads go to <data_home> or $GPODDER_DOWNLOAD_DIR
67
67
self .downloads = os .environ .get ('GPODDER_DOWNLOAD_DIR' , os .path .join (self .data_home ))
68
68
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
+
69
75
# Initialize the gPodder home directories
70
76
util .make_directory (self .data_home )
71
77
util .make_directory (self .config_home )
72
78
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
+
73
84
# Open the database and configuration file
74
85
self .db = database_class (database_file , verbose )
75
86
self .model = model_class (self )
76
- self .config = config_class (config_file )
77
87
78
88
# Load installed/configured plugins
79
89
self ._load_plugins ()
Original file line number Diff line number Diff line change @@ -128,9 +128,11 @@ def make_directory(path):
128
128
Tries to create a directory if it does not exist already.
129
129
Returns True if the directory exists after the function
130
130
call, False otherwise.
131
+ If the directory already exists it returns True if it is
132
+ writable.
131
133
"""
132
134
if os .path .isdir (path ):
133
- return True
135
+ return os . access ( path , os . W_OK )
134
136
135
137
try :
136
138
os .makedirs (path )
You can’t perform that action at this time.
0 commit comments