@@ -164,7 +164,14 @@ public File dataFile(String path) {
164
164
* @return true if a working data directory is configured
165
165
*/
166
166
public boolean isConfigured () {
167
- return dataDir != null && dataDir .exists ();
167
+ return dataDir != null && dataDir .isDirectory () && dataDir .list ().length > 0 ;
168
+ }
169
+
170
+ /**
171
+ * @return true if a working data directory is configured, but is not yet set up
172
+ */
173
+ public boolean isConfiguredButEmpty () {
174
+ return dataDir != null && dataDir .isDirectory () && dataDir .list ().length == 0 ;
168
175
}
169
176
170
177
/**
@@ -327,7 +334,7 @@ public boolean setDataDir(File dataDir) throws InvalidConfigException {
327
334
throw new InvalidConfigException (TYPE .INVALID_DATA_DIR ,
328
335
"DataDir " + dataDir .getAbsolutePath () + " exists already and is no IPT data dir." );
329
336
}
330
- LOG .info ("Reusing existing data dir." );
337
+ LOG .info ("Reusing existing data dir {}" , dataDir );
331
338
// persist location in WEB-INF
332
339
try {
333
340
persistLocation ();
@@ -343,6 +350,7 @@ public boolean setDataDir(File dataDir) throws InvalidConfigException {
343
350
344
351
} else {
345
352
// NEW datadir
353
+ LOG .info ("Setting up new data directory {}" , dataDir );
346
354
try {
347
355
// create new main data dir. Populate later
348
356
FileUtils .forceMkdir (dataDir );
@@ -353,8 +361,10 @@ public boolean setDataDir(File dataDir) throws InvalidConfigException {
353
361
testFile .delete ();
354
362
// create new default data dir
355
363
createDefaultDir ();
356
- // all works fine - persist location in WEB-INF
357
- persistLocation ();
364
+ if (dataDirSettingFile != null ) {
365
+ // all works fine - persist location in WEB-INF if that is how it is recorded
366
+ persistLocation ();
367
+ }
358
368
return true ;
359
369
} catch (IOException e ) {
360
370
LOG .error ("New DataDir " + dataDir .getAbsolutePath () + " not writable" , e );
0 commit comments