WorkingDir: Fix detection of migrated directory

This commit is contained in:
zzz
2012-02-10 21:54:43 +00:00
parent 4cea4514a0
commit 29c85254e7
3 changed files with 17 additions and 8 deletions

View File

@@ -1,3 +1,9 @@
2012-02-10 zzz
* WorkingDir: Fix detection of migrated directory
2012-02-09 zzz
* i2psnark: Escape semicolons
2012-02-04 zzz
* Deprecate util classes used only by installer
* ProfileOrganizer: Add profileOrganizer.sameCountryBonus config

View File

@@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */
public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 11;
public final static long BUILD = 12;
/** for example "-test" */
public final static String EXTRA = "";

View File

@@ -184,20 +184,23 @@ public class WorkingDir {
/**
* Tests if <code>dir</code> has been set up as a I2P working directory.<br/>
* Returns <code>false</code> if a directory is empty, or contains nothing besides
* subdirectories named <code>plugins</code> and/or <code>logs</code>.<br/>
* Returns <code>true</code> if the directory contains something not named
* <code>plugins</code> or <code>logs</code>.</br>
* Returns <code>false</code> if a directory is empty, or contains nothing that
* is usually migrated from the base install.
* This allows to pre-install plugins before the first router start.
* @return true if already set up
*/
private static boolean isSetup(File dir) {
if (dir.isDirectory()) {
String[] files = dir.list();
if (files == null)
return false;
for (String file: files)
if (!"plugins".equals(file) && !"logs".equals(file))
return true;
String migrated[] = MIGRATE_BASE.split(",");
for (String file: files) {
for (int i = 0; i < migrated.length; i++) {
if (file.equals(migrated[i]))
return true;
}
}
}
return false;
}