Bug 302766 - Test failures in org.eclipse.core.resources.semantic.test.suite
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/cacheservice/TemporaryFileHandle.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/cacheservice/TemporaryFileHandle.java
index 408178a..2aa6bc4 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/cacheservice/TemporaryFileHandle.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/internal/resources/semantic/cacheservice/TemporaryFileHandle.java
@@ -106,12 +106,12 @@
.getAbsolutePath()));
}
// TODO 0.1: non-millisecond accuracy systems
- long lastModified = this.cacheFile.lastModified();
- if (lastModified != timestamp) {
- throw new SemanticResourceException(SemanticResourceStatusCode.FILECACHE_ERROR_SETTING_TIMESTAMP, new Path(this.cacheFile
- .getAbsolutePath()), MessageFormat.format(Messages.TemporaryFileHandle_TimstampSetOnCommit_XMSG, this.cacheFile
- .getAbsolutePath()));
- }
+// long lastModified = this.cacheFile.lastModified();
+// if (lastModified != timestamp) {
+// throw new SemanticResourceException(SemanticResourceStatusCode.FILECACHE_ERROR_SETTING_TIMESTAMP, new Path(this.cacheFile
+// .getAbsolutePath()), MessageFormat.format(Messages.TemporaryFileHandle_TimstampSetOnCommit_XMSG, this.cacheFile
+// .getAbsolutePath()));
+// }
}
public IPath getKey() {
diff --git a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/CachingContentProvider.java b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/CachingContentProvider.java
index a444a1c..1edb29d 100644
--- a/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/CachingContentProvider.java
+++ b/bundles/org.eclipse.core.resources.semantic/src/org/eclipse/core/resources/semantic/spi/CachingContentProvider.java
@@ -28,8 +28,11 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.osgi.util.NLS;
+
+
/**
* This will delegate calls to openInputStream and openOutputStream to local
* copies of the semantic files.
@@ -59,6 +62,8 @@
*
*/
public abstract class CachingContentProvider extends ContentProvider {
+
+ private static final QualifiedName RESOURCE_TIMESTAMP = new QualifiedName(SemanticResourcesPlugin.PLUGIN_ID, "ResourceTimestamp"); //$NON-NLS-1$
// TODO 0.1: add convenience/helper methods to cleanup cache along with
// file/folder removal
// TODO 0.1: add helpers for write-through error handling
@@ -426,11 +431,19 @@
}
public long getResourceTimestamp(ISemanticFileStore semanticFileStore, IProgressMonitor monitor) throws CoreException {
+
+
+ String stampString = semanticFileStore.getPersistentProperty(RESOURCE_TIMESTAMP);
+ if (stampString != null){
+ return Long.parseLong(stampString);
+ }
+ // the cache service can also give some information, but depending on the
+ // underlying file system, precision may be seconds, not milliseconds
ICacheService cacheService = this.getCacheService();
IPath path = semanticFileStore.getPath();
long timestamp = cacheService.getContentTimestamp(path);
- if (timestamp >= 0) {
+ if (timestamp >= 0) {
return timestamp;
}
@@ -456,18 +469,24 @@
}
public void setResourceTimestamp(ISemanticFileStore semanticFileStore, long timestamp, IProgressMonitor monitor) throws CoreException {
+
+ semanticFileStore.setPersistentProperty(RESOURCE_TIMESTAMP, Long.toString(timestamp));
+
+ // we also update the cache information, but this is additional information only
ICacheService cacheService = this.getCacheService();
IPath path = semanticFileStore.getPath();
if (cacheService.hasContent(path)) {
cacheService.setContentTimestamp(path, timestamp);
- } else {
- // ugly as it is, this will set the timestamp on the cache file
- // properly
- InputStream is = openInputStream(semanticFileStore, monitor);
- Util.safeClose(is);
- cacheService.setContentTimestamp(path, timestamp);
}
+ // TODO we probably don't want to get a cache update, do we?
+// else {
+// // ugly as it is, this will set the timestamp on the cache file
+// // properly
+// InputStream is = openInputStream(semanticFileStore, monitor);
+// Util.safeClose(is);
+// cacheService.setContentTimestamp(path, timestamp);
+// }
}
}