diff options
author | Michael Valenta | 2003-10-14 20:46:55 +0000 |
---|---|---|
committer | Michael Valenta | 2003-10-14 20:46:55 +0000 |
commit | 24f489993ed63914faf02297c63bddc9815278d8 (patch) | |
tree | 116850562264e8685e839fe5640bf96387d3c94d | |
parent | ca690c9f94a6b416b01522d103aa52571ffbf1e2 (diff) | |
download | eclipse.platform.team-24f489993ed63914faf02297c63bddc9815278d8.tar.gz eclipse.platform.team-24f489993ed63914faf02297c63bddc9815278d8.tar.xz eclipse.platform.team-24f489993ed63914faf02297c63bddc9815278d8.zip |
44842: On startup, persisted merge subscriber is emptyI20031015
3 files changed, 30 insertions, 41 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ContentComparisonCriteria.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ContentComparisonCriteria.java index 989dbbbc8..b3aed9c6e 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ContentComparisonCriteria.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/ContentComparisonCriteria.java @@ -14,7 +14,7 @@ import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; -import org.eclipse.core.resources.IStorage; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.team.core.TeamException; @@ -150,8 +150,8 @@ public class ContentComparisonCriteria extends ComparisonCriteria { private InputStream getContents(Object resource, IProgressMonitor monitor) throws TeamException { try { - if (resource instanceof IStorage) { - return new BufferedInputStream(((IStorage) resource).getContents()); + if (resource instanceof IFile) { + return new BufferedInputStream(((IFile) resource).getContents()); } else if(resource instanceof IRemoteResource) { IRemoteResource remote = (IRemoteResource)resource; if (!remote.isContainer()) { diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteContentsCache.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteContentsCache.java index 18710e0dd..67b985c0c 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteContentsCache.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteContentsCache.java @@ -11,6 +11,7 @@ package org.eclipse.team.core.sync; import java.io.BufferedOutputStream; +import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; @@ -184,7 +185,8 @@ public class RemoteContentsCache { // We will end up here if we couldn't read or delete the cache file throw new TeamException(Policy.bind("RemoteContentsCache.fileError", ioFile.getAbsolutePath()), e); //$NON-NLS-1$ } - return null; + // This can occur when there is no remote contents + return new ByteArrayInputStream(new byte[0]); } /** diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java index 3643ecee4..87d6e0775 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java @@ -43,10 +43,10 @@ import org.eclipse.team.internal.ccvs.core.ICVSResourceVisitor; import org.eclipse.team.internal.ccvs.core.ILogEntry; import org.eclipse.team.internal.ccvs.core.Policy; import org.eclipse.team.internal.ccvs.core.client.Command; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; import org.eclipse.team.internal.ccvs.core.client.Log; import org.eclipse.team.internal.ccvs.core.client.Session; import org.eclipse.team.internal.ccvs.core.client.Update; +import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption; import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener; @@ -64,8 +64,6 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, IStora // sync info in byte form private byte[] syncBytes; - // buffer for file contents received from the server - private byte[] contents; // cache the log entry for the remote file private ILogEntry entry; @@ -164,29 +162,19 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, IStora * @see ICVSRemoteFile#getContents() */ public InputStream getContents(IProgressMonitor monitor) throws CVSException { - if (contents == null) { - // First, check to see if there's a cached contents for the file - InputStream cached = getCachedContents(); - if (cached != null) { - return cached; - } - - // No contents cached so fetch contents from the server. + // Ensure that the contents are cached from the server + if (!isContentsCached()) { fetchContents(monitor); - - // If the update succeeded but no contents were retreived from the server - // than we can assume that the remote file has no contents. - if (contents == null) { - // The above is true unless there is a cache file - cached = getCachedContents(); - if (cached != null) { - return cached; - } else { - contents = new byte[0]; - } - } } - return new ByteArrayInputStream(contents); + // If the fetch succeeded but no contents were cached from the server + // than we can assume that the remote file has no contents. + if (!isContentsCached()) { + setContents(new ByteArrayInputStream(new byte[0]), UPDATED, false /* keep history */, monitor); + } + // Return the cached contents + InputStream cached = getCachedContents(); + Assert.isNotNull(cached, "Caching error for file " + getRepositoryRelativePath()); //$NON-NLS-1$ + return cached; } /* package*/ void fetchContents(IProgressMonitor monitor) throws CVSException { @@ -317,13 +305,11 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, IStora * @see ICVSFile#getSize() */ public long getSize() { - if (contents == null) { - File ioFile = getRemoteContentsCache().getFile(getCacheRelativePath()); - if (ioFile.exists()) { - return ioFile.length(); - } + File ioFile = getRemoteContentsCache().getFile(getCacheRelativePath()); + if (ioFile.exists()) { + return ioFile.length(); } - return contents == null ? 0 : contents.length; + return 0; } /** @@ -377,14 +363,15 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, IStora } public InputStream getContents() throws CVSException { - if (contents == null) { - // Check for cached contents for the file - InputStream cached = getCachedContents(); - if (cached != null) { - return cached; - } + // Return the cached contents + InputStream cached = getCachedContents(); + if (cached != null) { + return cached; } - return new ByteArrayInputStream(contents == null ? new byte[0] : contents); + // There was nothing cached so return an empty stream. + // This is done to allow the contents to be fetched + // (i.e. update sends empty contents and real contents are sent back) + return new ByteArrayInputStream(new byte[0]); } private InputStream getCachedContents() throws CVSException { |