Missed this commit - Complete - task 141: Gridworks workspace directory not migrated to new Refine location on Windows or Linux
http://code.google.com/p/google-refine/issues/detail?id=141 git-svn-id: http://google-refine.googlecode.com/svn/trunk@1493 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
parent
dc49047092
commit
987fcacbee
@ -261,6 +261,7 @@ class RefineServer extends Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
File dataDir = null;
|
File dataDir = null;
|
||||||
|
File gridworksDir = null;
|
||||||
|
|
||||||
String os = System.getProperty("os.name").toLowerCase();
|
String os = System.getProperty("os.name").toLowerCase();
|
||||||
if (os.contains("windows")) {
|
if (os.contains("windows")) {
|
||||||
@ -271,9 +272,11 @@ class RefineServer extends Server {
|
|||||||
// it's not elegant but it's the safest bet.
|
// it's not elegant but it's the safest bet.
|
||||||
|
|
||||||
DataPath localDataPath = JDataPathSystem.getLocalSystem().getLocalDataPath("Google");
|
DataPath localDataPath = JDataPathSystem.getLocalSystem().getLocalDataPath("Google");
|
||||||
|
|
||||||
|
// new: ./Google/Refine old: ./Gridworks
|
||||||
dataDir = new File(new File(fixWindowsUnicodePath(localDataPath.getPath())), "Refine");
|
dataDir = new File(new File(fixWindowsUnicodePath(localDataPath.getPath())), "Refine");
|
||||||
|
gridworksDir = new File(fixWindowsUnicodePath(JDataPathSystem.getLocalSystem()
|
||||||
|
.getLocalDataPath("Gridworks").getPath()));
|
||||||
} catch (Error e) {
|
} catch (Error e) {
|
||||||
/*
|
/*
|
||||||
* The above trick can fail, particularly on a 64-bit OS as the jdatapath.dll
|
* The above trick can fail, particularly on a 64-bit OS as the jdatapath.dll
|
||||||
@ -301,42 +304,55 @@ class RefineServer extends Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dataDir = new File(new File(parentDir, "Google"), "Refine");
|
dataDir = new File(new File(parentDir, "Google"), "Refine");
|
||||||
|
gridworksDir = new File(parentDir, "Gridworks");
|
||||||
}
|
}
|
||||||
} else if (os.contains("mac os x")) {
|
} else if (os.contains("mac os x")) {
|
||||||
// on macosx, use "~/Library/Application Support"
|
// on macosx, use "~/Library/Application Support"
|
||||||
String home = System.getProperty("user.home");
|
String home = System.getProperty("user.home");
|
||||||
String data_home = (home != null) ? home + "/Library/Application Support/Google/Refine" : ".google-refine";
|
|
||||||
|
|
||||||
|
String data_home = (home != null) ? home + "/Library/Application Support/Google/Refine" : ".google-refine";
|
||||||
dataDir = new File(data_home);
|
dataDir = new File(data_home);
|
||||||
|
|
||||||
|
String gridworks_home = (home != null) ? home + "/Library/Application Support/Gridworks" : ".gridworks";
|
||||||
|
gridworksDir = new File(gridworks_home);
|
||||||
} else { // most likely a UNIX flavor
|
} else { // most likely a UNIX flavor
|
||||||
// start with the XDG environment
|
// start with the XDG environment
|
||||||
// see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
// see http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
String data_home = System.getenv("XDG_DATA_HOME");
|
String data_home = System.getenv("XDG_DATA_HOME");
|
||||||
if (data_home == null) { // if not found, default back to ~/.local/share
|
if (data_home == null) { // if not found, default back to ~/.local/share
|
||||||
String home = System.getProperty("user.home");
|
String home = System.getProperty("user.home");
|
||||||
if (home == null) home = ".";
|
if (home == null) {
|
||||||
|
home = ".";
|
||||||
|
}
|
||||||
data_home = home + "/.local/share";
|
data_home = home + "/.local/share";
|
||||||
}
|
}
|
||||||
|
|
||||||
dataDir = new File(data_home + "/google-refine");
|
dataDir = new File(data_home + "/google/refine");
|
||||||
|
gridworksDir = new File(data_home + "/gridworks");
|
||||||
}
|
}
|
||||||
|
|
||||||
// If refine data dir doesn't exist, try to find and move gridworks data dir over
|
// If refine data dir doesn't exist, try to find and move gridworks data dir over
|
||||||
if (!dataDir.exists()) {
|
if (!dataDir.exists() && gridworksDir.exists()) {
|
||||||
File gridworksDir;
|
if (!dataDir.getParentFile().mkdirs()) {
|
||||||
if (dataDir.getName().equals("Refine")) {
|
logger.error("FAILED to create parent directory for workspace rename target "
|
||||||
gridworksDir = new File(dataDir.getParentFile().getParentFile(), "Gridworks");
|
+ dataDir.getParent());
|
||||||
} else if (dataDir.getName().startsWith(".")) {
|
|
||||||
gridworksDir = new File(dataDir.getParent(), ".gridworks");
|
|
||||||
} else {
|
} else {
|
||||||
gridworksDir = new File(dataDir.getParent(), ".gridworks");
|
if (gridworksDir.renameTo(dataDir)) {
|
||||||
|
logger.info("Renamed Gridworks directory " + gridworksDir
|
||||||
|
+ " to " + dataDir);
|
||||||
|
} else {
|
||||||
|
logger.error("FAILED to rename Gridworks directory "
|
||||||
|
+ gridworksDir
|
||||||
|
+ " to " + dataDir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (gridworksDir.exists()) {
|
|
||||||
gridworksDir.renameTo(dataDir);
|
// Either rename failed or nothing to rename - create a new one
|
||||||
} else {
|
if (!dataDir.exists()) {
|
||||||
dataDir.mkdirs();
|
logger.info("Creating new workspace directory " + dataDir);
|
||||||
|
if (!dataDir.mkdirs()) {
|
||||||
|
logger.error("FAILED to create new workspace directory " + dataDir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user