mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
init: Moved permissions check earlier in the processing
This commit is contained in:
parent
7db6f68b92
commit
726ac35a44
1 changed files with 9 additions and 9 deletions
18
src/init.cpp
18
src/init.cpp
|
@ -113,6 +113,15 @@ void initializeDataAndRules (
|
||||||
char* override = getenv ("TIMEWARRIORDB");
|
char* override = getenv ("TIMEWARRIORDB");
|
||||||
dbLocation = Directory (override ? override : "~/.timewarrior");
|
dbLocation = Directory (override ? override : "~/.timewarrior");
|
||||||
|
|
||||||
|
// If dbLocation exists, but is not readable/writable/executable, error.
|
||||||
|
if (dbLocation.exists () &&
|
||||||
|
(! dbLocation.readable () ||
|
||||||
|
! dbLocation.writable () ||
|
||||||
|
! dbLocation.executable ()))
|
||||||
|
{
|
||||||
|
throw format ("Database is not readable at '{1}'", dbLocation._data);
|
||||||
|
}
|
||||||
|
|
||||||
// If dbLocation does not exist, ask whether it should be created.
|
// If dbLocation does not exist, ask whether it should be created.
|
||||||
bool shinyNewDatabase = false;
|
bool shinyNewDatabase = false;
|
||||||
if (! dbLocation.exists () &&
|
if (! dbLocation.exists () &&
|
||||||
|
@ -134,15 +143,6 @@ void initializeDataAndRules (
|
||||||
if (! data.exists ())
|
if (! data.exists ())
|
||||||
data.create (0700);
|
data.create (0700);
|
||||||
|
|
||||||
// If dbLocation exists, but is not readable/writable/executable, error.
|
|
||||||
if (dbLocation.exists () &&
|
|
||||||
(! dbLocation.readable () ||
|
|
||||||
! dbLocation.writable () ||
|
|
||||||
! dbLocation.executable ()))
|
|
||||||
{
|
|
||||||
throw format ("Database is not readable at '{1}'", dbLocation._data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load the configuration data.
|
// Load the configuration data.
|
||||||
File configFile (dbLocation);
|
File configFile (dbLocation);
|
||||||
configFile += "timewarrior.cfg";
|
configFile += "timewarrior.cfg";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue