### Eclipse Workspace Patch 1.0 #P org.eclipse.core.resources Index: src/org/eclipse/core/internal/resources/Project.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Project.java,v retrieving revision 1.168 diff -u -r1.168 Project.java --- src/org/eclipse/core/internal/resources/Project.java 29 Mar 2010 14:01:26 -0000 1.168 +++ src/org/eclipse/core/internal/resources/Project.java 14 Apr 2010 19:22:31 -0000 @@ -28,6 +28,8 @@ import org.eclipse.osgi.util.NLS; public class Project extends Container implements IProject { + + private URI snapshotPath = null; protected Project(IPath path, Workspace container) { super(path, container); @@ -837,9 +839,7 @@ throw new CoreException(status); } // copy the snapshot from the URI into the project metadata - IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(this); - IFileStore snapshotFileStore = EFS.getStore(org.eclipse.core.filesystem.URIUtil.toURI(snapshotPath)); - EFS.getStore(snapshotLocation).copy(snapshotFileStore, EFS.OVERWRITE, monitor); + snapshotPath = snapshotLocation; } } /* (non-Javadoc) @@ -949,7 +949,7 @@ boolean refreshed = false; if (!used) { refreshed = workspace.getSaveManager().restoreFromRefreshSnapshot( - this, Policy.subMonitorFor(monitor, Policy.opWork * 20 / 100)); + this, snapshotPath, Policy.subMonitorFor(monitor, Policy.opWork * 20 / 100)); if (refreshed) { // account for the refresh work monitor.worked(Policy.opWork * 60 / 100); } Index: src/org/eclipse/core/internal/resources/SaveManager.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java,v retrieving revision 1.103 diff -u -r1.103 SaveManager.java --- src/org/eclipse/core/internal/resources/SaveManager.java 4 Mar 2010 23:02:51 -0000 1.103 +++ src/org/eclipse/core/internal/resources/SaveManager.java 14 Apr 2010 19:22:32 -0000 @@ -11,17 +11,12 @@ *******************************************************************************/ package org.eclipse.core.internal.resources; -import org.eclipse.core.runtime.OperationCanceledException; - -import org.eclipse.core.filesystem.IFileStore; - -import org.eclipse.core.filesystem.EFS; - -import java.net.URI; - import java.io.*; +import java.net.URI; import java.util.*; -import java.util.zip.*; +import java.util.zip.ZipOutputStream; +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.internal.events.*; import org.eclipse.core.internal.localstore.*; import org.eclipse.core.internal.utils.*; @@ -725,12 +720,16 @@ * and false if the refresh snapshot was not found or could not be opened. * @exception CoreException if an error occurred reading the snapshot file. */ - protected boolean restoreFromRefreshSnapshot(Project project, + protected boolean restoreFromRefreshSnapshot(Project project, URI snapshotLocation, IProgressMonitor monitor) throws CoreException { boolean status = true; - IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(project); - java.io.File snapshotFile = snapshotPath.toFile(); - if (!snapshotFile.exists()) + //IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(project); + //java.io.File snapshotFile = snapshotPath.toFile(); + if (snapshotLocation==null) { + return false; + } + java.io.File snapshotFile = EFS.getStore(snapshotLocation).toLocalFile(EFS.NONE, null); + if (snapshotFile==null || !snapshotFile.exists()) return false; if (Policy.DEBUG_RESTORE) System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$ @@ -1031,19 +1030,19 @@ try { monitor.beginTask("", Policy.totalWork); //$NON-NLS-1$ InputStream snapIn = new FileInputStream(snapshotFile); - ZipInputStream zip = new ZipInputStream(snapIn); - ZipEntry treeEntry = zip.getNextEntry(); - if (treeEntry == null || !treeEntry.getName().equals("resource-index.tree")) { //$NON-NLS-1$ - zip.close(); - return false; - } - DataInputStream input = new DataInputStream(zip); + //ZipInputStream zip = new ZipInputStream(snapIn); + //ZipEntry treeEntry = zip.getNextEntry(); + //if (treeEntry == null || !treeEntry.getName().equals("resource-index.tree")) { //$NON-NLS-1$ + // zip.close(); + // return false; + //} + DataInputStream input = new DataInputStream(snapIn); try { WorkspaceTreeReader reader = WorkspaceTreeReader.getReader(workspace, input.readInt()); reader.readTree(project, input, Policy.subMonitorFor(monitor, Policy.totalWork)); } finally { input.close(); - zip.close(); + snapIn.close(); } } catch (IOException e) { snapshotPath = new Path(snapshotFile.getPath()); @@ -1278,20 +1277,21 @@ output.close(); } OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor); - out = new ZipOutputStream(snapOut); - out.setLevel(Deflater.BEST_COMPRESSION); - ZipEntry e = new ZipEntry("resource-index.tree"); //$NON-NLS-1$ - out.putNextEntry(e); + //out = new ZipOutputStream(snapOut); + //out.setLevel(Deflater.BEST_COMPRESSION); + //ZipEntry e = new ZipEntry("resource-index.tree"); //$NON-NLS-1$ + //out.putNextEntry(e); int read = 0; byte[] buffer = new byte[4096]; InputStream in = new FileInputStream(tmpTree); try { while ((read = in.read(buffer)) >= 0) { - out.write(buffer, 0, read); + snapOut.write(buffer, 0, read); } - out.closeEntry(); + //out.closeEntry(); } finally { in.close(); + snapOut.close(); } } catch (IOException e) { throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e);