View | Details | Raw Unified | Return to bug 305717
Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/Project.java (-4 / +4 lines)
Lines 28-33 Link Here
28
import org.eclipse.osgi.util.NLS;
28
import org.eclipse.osgi.util.NLS;
29
29
30
public class Project extends Container implements IProject {
30
public class Project extends Container implements IProject {
31
	
32
	private URI snapshotPath = null;
31
33
32
	protected Project(IPath path, Workspace container) {
34
	protected Project(IPath path, Workspace container) {
33
		super(path, container);
35
		super(path, container);
Lines 837-845 Link Here
837
				throw new CoreException(status);
839
				throw new CoreException(status);
838
			}
840
			}
839
			// copy the snapshot from the URI into the project metadata
841
			// copy the snapshot from the URI into the project metadata
840
			IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(this);
842
			snapshotPath = snapshotLocation;
841
			IFileStore snapshotFileStore = EFS.getStore(org.eclipse.core.filesystem.URIUtil.toURI(snapshotPath));
842
			EFS.getStore(snapshotLocation).copy(snapshotFileStore, EFS.OVERWRITE, monitor);
843
		}
843
		}
844
	}
844
	}
845
	/* (non-Javadoc)
845
	/* (non-Javadoc)
Lines 949-955 Link Here
949
					boolean refreshed = false;
949
					boolean refreshed = false;
950
					if (!used) {
950
					if (!used) {
951
						refreshed = workspace.getSaveManager().restoreFromRefreshSnapshot(
951
						refreshed = workspace.getSaveManager().restoreFromRefreshSnapshot(
952
								this, Policy.subMonitorFor(monitor, Policy.opWork * 20 / 100));
952
								this, snapshotPath, Policy.subMonitorFor(monitor, Policy.opWork * 20 / 100));
953
						if (refreshed) {	// account for the refresh work
953
						if (refreshed) {	// account for the refresh work
954
							monitor.worked(Policy.opWork * 60 / 100);
954
							monitor.worked(Policy.opWork * 60 / 100);
955
						}
955
						}
(-)src/org/eclipse/core/internal/resources/SaveManager.java (-27 / +27 lines)
Lines 11-27 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.core.internal.resources;
12
package org.eclipse.core.internal.resources;
13
13
14
import org.eclipse.core.runtime.OperationCanceledException;
15
16
import org.eclipse.core.filesystem.IFileStore;
17
18
import org.eclipse.core.filesystem.EFS;
19
20
import java.net.URI;
21
22
import java.io.*;
14
import java.io.*;
15
import java.net.URI;
23
import java.util.*;
16
import java.util.*;
24
import java.util.zip.*;
17
import java.util.zip.ZipOutputStream;
18
import org.eclipse.core.filesystem.EFS;
19
import org.eclipse.core.filesystem.IFileStore;
25
import org.eclipse.core.internal.events.*;
20
import org.eclipse.core.internal.events.*;
26
import org.eclipse.core.internal.localstore.*;
21
import org.eclipse.core.internal.localstore.*;
27
import org.eclipse.core.internal.utils.*;
22
import org.eclipse.core.internal.utils.*;
Lines 725-736 Link Here
725
	 * and <code>false</code> if the refresh snapshot was not found or could not be opened.
720
	 * and <code>false</code> if the refresh snapshot was not found or could not be opened.
726
	 * @exception CoreException if an error occurred reading the snapshot file.
721
	 * @exception CoreException if an error occurred reading the snapshot file.
727
	 */
722
	 */
728
	protected boolean restoreFromRefreshSnapshot(Project project,
723
	protected boolean restoreFromRefreshSnapshot(Project project, URI snapshotLocation,
729
			IProgressMonitor monitor) throws CoreException {
724
			IProgressMonitor monitor) throws CoreException {
730
		boolean status = true;
725
		boolean status = true;
731
		IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(project);
726
		//IPath snapshotPath = workspace.getMetaArea().getRefreshLocationFor(project);
732
		java.io.File snapshotFile = snapshotPath.toFile();
727
		//java.io.File snapshotFile = snapshotPath.toFile();
733
		if (!snapshotFile.exists())
728
		if (snapshotLocation==null) {
729
			return false;
730
		}
731
		java.io.File snapshotFile = EFS.getStore(snapshotLocation).toLocalFile(EFS.NONE, null);
732
		if (snapshotFile==null || !snapshotFile.exists())
734
			return false;
733
			return false;
735
		if (Policy.DEBUG_RESTORE)
734
		if (Policy.DEBUG_RESTORE)
736
			System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$
735
			System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$
Lines 1031-1049 Link Here
1031
		try {
1030
		try {
1032
			monitor.beginTask("", Policy.totalWork); //$NON-NLS-1$
1031
			monitor.beginTask("", Policy.totalWork); //$NON-NLS-1$
1033
			InputStream snapIn = new FileInputStream(snapshotFile);
1032
			InputStream snapIn = new FileInputStream(snapshotFile);
1034
			ZipInputStream zip = new ZipInputStream(snapIn);
1033
			//ZipInputStream zip = new ZipInputStream(snapIn);
1035
			ZipEntry treeEntry = zip.getNextEntry();
1034
			//ZipEntry treeEntry = zip.getNextEntry();
1036
			if (treeEntry == null || !treeEntry.getName().equals("resource-index.tree")) { //$NON-NLS-1$
1035
			//if (treeEntry == null || !treeEntry.getName().equals("resource-index.tree")) { //$NON-NLS-1$
1037
				zip.close();
1036
			//	zip.close();
1038
				return false;
1037
			//	return false;
1039
			}
1038
			//}
1040
			DataInputStream input = new DataInputStream(zip);
1039
			DataInputStream input = new DataInputStream(snapIn);
1041
			try {
1040
			try {
1042
				WorkspaceTreeReader reader = WorkspaceTreeReader.getReader(workspace, input.readInt());
1041
				WorkspaceTreeReader reader = WorkspaceTreeReader.getReader(workspace, input.readInt());
1043
				reader.readTree(project, input, Policy.subMonitorFor(monitor, Policy.totalWork));
1042
				reader.readTree(project, input, Policy.subMonitorFor(monitor, Policy.totalWork));
1044
			} finally {
1043
			} finally {
1045
				input.close();
1044
				input.close();
1046
				zip.close();
1045
				snapIn.close();
1047
			}
1046
			}
1048
		} catch (IOException e) {
1047
		} catch (IOException e) {
1049
			snapshotPath = new Path(snapshotFile.getPath());
1048
			snapshotPath = new Path(snapshotFile.getPath());
Lines 1278-1297 Link Here
1278
				output.close();
1277
				output.close();
1279
			}
1278
			}
1280
			OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor);
1279
			OutputStream snapOut = store.openOutputStream(EFS.NONE, monitor);
1281
			out = new ZipOutputStream(snapOut);
1280
			//out = new ZipOutputStream(snapOut);
1282
			out.setLevel(Deflater.BEST_COMPRESSION);
1281
			//out.setLevel(Deflater.BEST_COMPRESSION);
1283
			ZipEntry e = new ZipEntry("resource-index.tree"); //$NON-NLS-1$
1282
			//ZipEntry e = new ZipEntry("resource-index.tree"); //$NON-NLS-1$
1284
			out.putNextEntry(e);
1283
			//out.putNextEntry(e);
1285
			int read = 0;
1284
			int read = 0;
1286
			byte[] buffer = new byte[4096];
1285
			byte[] buffer = new byte[4096];
1287
			InputStream in = new FileInputStream(tmpTree);
1286
			InputStream in = new FileInputStream(tmpTree);
1288
			try {
1287
			try {
1289
				while ((read = in.read(buffer)) >= 0) {
1288
				while ((read = in.read(buffer)) >= 0) {
1290
					out.write(buffer, 0, read);
1289
					snapOut.write(buffer, 0, read);
1291
				}
1290
				}
1292
				out.closeEntry();
1291
				//out.closeEntry();
1293
			} finally {
1292
			} finally {
1294
				in.close();
1293
				in.close();
1294
				snapOut.close();
1295
			}
1295
			}
1296
		} catch (IOException e) {
1296
		} catch (IOException e) {
1297
			throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e);
1297
			throw new ResourceException(IResourceStatus.FAILED_WRITE_LOCAL, snapshotPath, Messages.resources_copyProblem, e);

Return to bug 305717