Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten2007-06-27 10:08:50 -0400
committermkersten2007-06-27 10:08:50 -0400
commit92d8d1034334129f86ac5968ff10eca96cf8ea9b (patch)
tree86264ffbe2822e974b76f1e5ffe148a7760478a0
parentb824fcbfa9cfc3ab5f8ce8fc0d85afe47e784e41 (diff)
downloadorg.eclipse.mylyn.tasks-92d8d1034334129f86ac5968ff10eca96cf8ea9b.tar.gz
org.eclipse.mylyn.tasks-92d8d1034334129f86ac5968ff10eca96cf8ea9b.tar.xz
org.eclipse.mylyn.tasks-92d8d1034334129f86ac5968ff10eca96cf8ea9b.zip
Version update
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java31
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java38
2 files changed, 38 insertions, 31 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java
index b244677db..e6b2ce0ce 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/WorkspaceAwareContextStore.java
@@ -10,9 +10,7 @@ package org.eclipse.mylyn.internal.tasks.ui;
import java.io.File;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.mylyn.context.core.AbstractContextStore;
-import org.eclipse.mylyn.monitor.core.StatusHandler;
import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
/**
@@ -20,10 +18,6 @@ import org.eclipse.mylyn.tasks.ui.TasksUiPlugin;
*/
public class WorkspaceAwareContextStore extends AbstractContextStore {
- private static final String DIRECTORY_METADATA = ".metadata";
-
- private static final String OLD_DATA_DIR = ".mylar";
-
public static final String CONTEXTS_DIRECTORY = "contexts";
private File rootDirectory;
@@ -31,30 +25,7 @@ public class WorkspaceAwareContextStore extends AbstractContextStore {
private File contextDirectory;
@Override
- public void init() {
- // Migrate .mylar data folder to .metadata/.mylyn
- String oldDefaultDataPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + '/'
- + OLD_DATA_DIR;
- File newDefaultDataDir = new File(TasksUiPlugin.getDefault().getDefaultDataDirectory());
- File oldDefaultDataDir = new File(oldDefaultDataPath);
- if (newDefaultDataDir.exists() && oldDefaultDataDir.exists()) {
- StatusHandler.log("Legacy data folder detected: " + oldDefaultDataDir.getAbsolutePath(), this);
- } else if (oldDefaultDataDir.exists() && !newDefaultDataDir.exists()) {
- File metadata = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + '/'
- + DIRECTORY_METADATA);
- if (!metadata.exists()) {
- if (!metadata.mkdirs()) {
- StatusHandler.log("Unable to create metadata folder: " + metadata.getAbsolutePath(), this);
- }
- }
-
- if (metadata.exists()) {
- if (!oldDefaultDataDir.renameTo(new File(TasksUiPlugin.getDefault().getDefaultDataDirectory()))) {
- StatusHandler.log("Failed to migrate legacy data from " + oldDefaultDataDir.getAbsolutePath()
- + " to " + TasksUiPlugin.getDefault().getDefaultDataDirectory(), this);
- }
- }
- }
+ public synchronized void init() {
rootDirectory = new File(TasksUiPlugin.getDefault().getDataDirectory());
if (!rootDirectory.exists()) {
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
index 5e73d8466..7c3c59124 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/tasks/ui/TasksUiPlugin.java
@@ -533,10 +533,46 @@ public class TasksUiPlugin extends AbstractUIPlugin implements IStartup {
+ NAME_DATA_DIR;
}
- public String getDataDirectory() {
+ /**
+ * Only attempt once per startup.
+ */
+ private boolean attemptMigration = true;
+
+ public synchronized String getDataDirectory() {
+ if (attemptMigration) {
+ migrateFromLegacyDirectory();
+ attemptMigration = false;
+ }
+// return ContextCorePlugin.getDefault().getContextStore().getRootDirectory().getAbsolutePath();
return getPreferenceStore().getString(ContextPreferenceContstants.PREF_DATA_DIR);
}
+ private void migrateFromLegacyDirectory() {
+ // Migrate .mylar data folder to .metadata/.mylyn
+ String oldDefaultDataPath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + '/'
+ + ".mylar";
+ File oldDefaultDataDir = new File(oldDefaultDataPath);
+ if (oldDefaultDataDir.exists()) { // && !newDefaultDataDir.exists()) {
+ File metadata = new File(ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() + '/'
+ + DIRECTORY_METADATA);
+ if (!metadata.exists()) {
+ if (!metadata.mkdirs()) {
+ StatusHandler.log("Unable to create metadata folder: " + metadata.getAbsolutePath(), this);
+ }
+ }
+ File newDefaultDataDir = new File(getPreferenceStore().getString(ContextPreferenceContstants.PREF_DATA_DIR));
+ if (metadata.exists()) {
+ if (!oldDefaultDataDir.renameTo(newDefaultDataDir)) {
+ StatusHandler.log("Could not migrate legacy data from " + oldDefaultDataDir.getAbsolutePath()
+ + " to " + TasksUiPlugin.getDefault().getDefaultDataDirectory(), this);
+ } else {
+ StatusHandler.log("Migrated legacy task data from " + oldDefaultDataDir.getAbsolutePath()
+ + " to " + TasksUiPlugin.getDefault().getDefaultDataDirectory(), this);
+ }
+ }
+ }
+ }
+
public void setDataDirectory(String newPath) {
getTaskListManager().saveTaskList();
ContextCorePlugin.getContextManager().saveActivityContext();

Back to the top