Create user doesn’t work if DBPATH folder does not exist
Hello all,
I just faced an issue in my application using BaseX 8.6.4 when trying to create a user.
If the folder that will contain the databases (DBPATH in .basex configuration file) does not exist when you try to create a user, the creation of the “users.xml” file fails.
To reproduce, make sure that the folder defined by DBPATH does not exist, and execute:
final Context ctx = new Context();
try (final Session session = new LocalSession(ctx);) {session.execute(new CreateUser("USERNAME", "USERPASSWORD"));
}
Then nothing happens. The users.xml file is not created.
While executing this:
final Context ctx = new Context();
try (final Session session = new LocalSession(ctx);) {session.execute(new CreateDB("TESTDB"));
session.execute(new CreateUser("USERNAME", "USERPASSWORD"));
}
Works as expected as the CreateDB() command will create the missing folder.
Is it on purpose or was it overlooked?
Best regards
Simon Chatelain
Dear Simon,
Thanks for the hint, the problem has been fixed [1,2]. We forgot to create the directory because in former times the user data was not stored in the db directory.
Best, Christian
[1] https://github.com/BaseXdb/basex/commit/a8ed0936ab422e3cb3a260c9ebfa47dd0e753a85 [2] http://files.basex.org/releases/latest/
Quoted text · Simon Chatelain · 55 lines
On Wed, May 31, 2017 at 1:34 PM, Simon Chatelain <schatela at gmail.com> wrote: > Hello all, > > > > I just faced an issue in my application using BaseX 8.6.4 when trying to > create a user. > > > If the folder that will contain the databases (DBPATH in .basex > configuration file) does not exist when you try to create a user, the > creation of the “users.xml” file fails. > > To reproduce, make sure that the folder defined by DBPATH does not exist, > and execute: > > > final Context ctx = new Context(); > > try (final Session session = new LocalSession(ctx);) { > > session.execute(new CreateUser("USERNAME", "USERPASSWORD")); > > } > > > Then nothing happens. The users.xml file is not created. > > While executing this: > > > final Context ctx = new Context(); > > try (final Session session = new LocalSession(ctx);) { > > session.execute(new CreateDB("TESTDB")); > > session.execute(new CreateUser("USERNAME", "USERPASSWORD")); > > } > > > Works as expected as the CreateDB() command will create the missing folder. > > > > Is it on purpose or was it overlooked? > > > > Best regards > > > > Simon Chatelain
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.