public bool Equals(IDependencyFingerprint other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } if (other.GetType() != this.GetType()) { return(false); } return(Equals((FSRepositoryFingerprint)other)); }
/// <summary> /// Checks if the cache contains stored outputs for a given builder with a given dependency fingerprint /// /// <para>If <see cref="IBuildCache.Restore"/> will be also called, the cache must be locked first using /// the <see cref="IBuildCache.LockForBuilder"/> method.</para> /// </summary> /// <param name="builder">Builder key</param> /// <param name="fingerprint">Current dependency fingerprint</param> /// <returns>Returns <c>true</c> if there are stored outputs for the given builder and fingerprint combination.</returns> public bool Contains(BuildKey builder, IDependencyFingerprint fingerprint) { var lck = GetOrCreateLock(builder); lck.EnterReadLock(); try { var dirName = GetCacheDirectoryName(builder); if (cacheRoot.ChildDirectories.Contains(dirName)) { var cacheDir = cacheRoot.GetChildDirectory(dirName); if (cacheDir.Files.Contains(DepsFileName)) { using (var depsStream = cacheDir.ReadBinaryFile(DepsFileName)) { var fpType = fingerprint.GetType(); var storedFp = Activator.CreateInstance(fpType, protocolSerializer, depsStream); bool fingerprintEquals = fingerprint.Equals(storedFp); if (!fingerprintEquals && EnableFingerprintDiff) { log.DebugFormat("[{0}] Fingerprint differs", dirName); log.DebugFormat("[{1}] Cached: {0}", storedFp, dirName); log.DebugFormat("[{1}] Current: {0}", fingerprint, dirName); } return(fingerprintEquals); } } } return(false); } finally { lck.ExitReadLock(); } }
/// <summary> /// Checks if the cache contains stored outputs for a given builder with a given dependency fingerprint /// /// <para>If <see cref="IBuildCache.Restore"/> will be also called, the cache must be locked first using /// the <see cref="IBuildCache.LockForBuilder"/> method.</para> /// </summary> /// <param name="builder">Builder key</param> /// <param name="fingerprint">Current dependency fingerprint</param> /// <returns>Returns <c>true</c> if there are stored outputs for the given builder and fingerprint combination.</returns> public bool Contains(BuildKey builder, IDependencyFingerprint fingerprint) { var lck = GetOrCreateLock(builder); lck.EnterReadLock(); try { var dirName = GetCacheDirectoryName(builder); if (cacheRoot.ChildDirectories.Contains(dirName)) { var cacheDir = cacheRoot.GetChildDirectory(dirName); if (cacheDir.Files.Contains(DepsFileName)) { using (var depsStream = cacheDir.ReadBinaryFile(DepsFileName)) { var fpType = fingerprint.GetType(); var storedFp = Activator.CreateInstance(fpType, protocolSerializer, depsStream); bool fingerprintEquals = fingerprint.Equals(storedFp); if (!fingerprintEquals && EnableFingerprintDiff) { log.DebugFormat("[{0}] Fingerprint differs", dirName); log.DebugFormat("[{1}] Cached: {0}", storedFp, dirName); log.DebugFormat("[{1}] Current: {0}", fingerprint, dirName); } return fingerprintEquals; } } } return false; } finally { lck.ExitReadLock(); } }