cozy / python_cozy_management

Python module to manage self hosted cozy
GNU Lesser General Public License v3.0
1 stars 5 forks source link

Improve get_database_dir #23

Open clochix opened 7 years ago

clochix commented 7 years ago

For now, to get the value of database_dir, we parse every configuration file we fond and get the first value of database_dir. This may not be accurate. A more accurate way (but which require the database to be up and running) would be to query the /_config url:

curl -s $(sed -n '1,1p' /etc/cozy/couchdb.login):$(sed -n '2,1p' /etc/cozy/couchdb.login)@127.0.0.1:5984/_config | jq -r '.couchdb.database_dir'
clochix commented 7 years ago

This is in fact a bug. When users move their database to another location, they add a new database_dir directive in /etc/couchdb/local.init but get_database_dir will only return the first one, from default.ini. This may be a serious issue, causing the backup command to not backup the right database folder if it has been moved elsewhere. So we should either update get_database_dir to get the config of the running database, or use config from local.ini if it exists when performing backups.

Ping @nledez