Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2009-09-09 17:56:26 +0000
committerspingel2009-09-09 17:56:26 +0000
commit7fdf7252caeb4533b5be6363497ac8081f6ea10b (patch)
tree382252f43501769ecb61e247bebd565a85d3c474
parent85a611d49ae41b2c059ae013a4077812060629ca (diff)
downloadorg.eclipse.mylyn.tasks-7fdf7252caeb4533b5be6363497ac8081f6ea10b.tar.gz
org.eclipse.mylyn.tasks-7fdf7252caeb4533b5be6363497ac8081f6ea10b.tar.xz
org.eclipse.mylyn.tasks-7fdf7252caeb4533b5be6363497ac8081f6ea10b.zip
NEW - bug 251473: [externalization] task list not restored after out of memory error
https://bugs.eclipse.org/bugs/show_bug.cgi?id=251473
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java14
-rw-r--r--org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java33
2 files changed, 21 insertions, 26 deletions
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java
index ff8711fa2..df83d1ec9 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/TaskListBackupManager.java
@@ -12,9 +12,7 @@
package org.eclipse.mylyn.internal.tasks.ui;
import java.io.File;
-import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;
-import com.ibm.icu.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
@@ -39,6 +37,8 @@ import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.progress.IProgressService;
+import com.ibm.icu.text.SimpleDateFormat;
+
/**
* @author Rob Elves
*/
@@ -140,7 +140,8 @@ public class TaskListBackupManager implements IPropertyChangeListener {
IProgressService service = PlatformUI.getWorkbench().getProgressService();
service.run(false, true, backupJob);
}
- } catch (InvocationTargetException e) {
+ } catch (InterruptedException e) {
+ } catch (Throwable e) {
if (!errorDisplayed) {
final Status status = new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN,
Messages.TaskListBackupManager_Error_occured_during_scheduled_tasklist_backup, e);
@@ -158,8 +159,11 @@ public class TaskListBackupManager implements IPropertyChangeListener {
});
}
}
- } catch (InterruptedException e) {
- return;
+
+ // clean up corrupt backup file
+ if (backupJob.getDestinationFile() != null) {
+ backupJob.getDestinationFile().delete();
+ }
}
}
diff --git a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java
index 040d49ac9..8ed4403ce 100644
--- a/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java
+++ b/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/util/TaskDataExportOperation.java
@@ -12,6 +12,7 @@
package org.eclipse.mylyn.internal.tasks.ui.util;
import java.io.File;
+import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashSet;
@@ -19,13 +20,10 @@ import java.util.Set;
import java.util.regex.Pattern;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.net.Policy;
import org.eclipse.mylyn.internal.commons.core.ZipFileUtil;
import org.eclipse.mylyn.internal.tasks.core.ITasksCoreConstants;
@@ -36,9 +34,7 @@ import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
*
* @author Wesley Coelho
* @author Mik Kersten
- * @author Rob Elves
- *
- * TODO: Move into internal.tasks.core
+ * @author Rob Elves TODO: Move into internal.tasks.core
*/
@SuppressWarnings("restriction")
public class TaskDataExportOperation implements IRunnableWithProgress {
@@ -58,11 +54,10 @@ public class TaskDataExportOperation implements IRunnableWithProgress {
this.destinationDirectory = destinationDirectory;
}
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-
+ public void run(IProgressMonitor monitor) throws InvocationTargetException {
monitor = Policy.monitorFor(monitor);
- Set<File> filesToExport = new HashSet<File>();
+ Set<File> filesToExport = new HashSet<File>();
selectFiles(filesToExport);
if (filesToExport.size() > 0 && Platform.isRunning()) {
@@ -71,26 +66,22 @@ public class TaskDataExportOperation implements IRunnableWithProgress {
Job.getJobManager().beginRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE,
new SubProgressMonitor(monitor, 1));
- File destZipFile = new File(destinationDirectory + File.separator + destinationFilename);
- //TODO: append a (2) to the file?
- if (destZipFile.exists()) {
- destZipFile.delete();
- }
-
- ZipFileUtil.createZipFile(destZipFile, new ArrayList<File>(filesToExport), TasksUiPlugin.getDefault()
- .getDataDirectory(), monitor);
- } catch (Exception e) {
- StatusHandler.fail(new Status(IStatus.ERROR, TasksUiPlugin.ID_PLUGIN, "Could not perform export", //$NON-NLS-1$
- e));
+ ZipFileUtil.createZipFile(getDestinationFile(), new ArrayList<File>(filesToExport),
+ TasksUiPlugin.getDefault().getDataDirectory(), monitor);
+ } catch (IOException e) {
+ throw new InvocationTargetException(e);
} finally {
-
Job.getJobManager().endRule(ITasksCoreConstants.ROOT_SCHEDULING_RULE);
monitor.done();
}
}
}
+ public File getDestinationFile() {
+ return new File(destinationDirectory + File.separator + destinationFilename);
+ }
+
protected void selectFiles(Set<File> filesToExport) {
Set<Pattern> exclusionPatterns = new HashSet<Pattern>();
exclusionPatterns.add(excludeHidden);

Back to the top