private void CheckApplicationPayload(CommitApplicationParams commitParams) { if ((commitParams.AppGroup == null) && (commitParams.appType != AppType.CustomHostSpecified)) { SystemUtils.CheckSupportedImageAndCLRVersions(Path.Combine(commitParams.AppPayloadPath, commitParams.AppManifest.EntryPoints[0].CommandFile)); } string directoryName = null; System.Deployment.Internal.Isolation.Store.IPathLock @lock = null; try { @lock = this._compStore.LockAssemblyPath(commitParams.AppManifest.Identity); directoryName = Path.GetDirectoryName(@lock.Path); directoryName = Path.Combine(directoryName, "manifests"); directoryName = Path.Combine(directoryName, Path.GetFileName(@lock.Path) + ".manifest"); } catch (DeploymentException) { } catch (COMException) { } finally { if (@lock != null) { @lock.Dispose(); } } if ((!string.IsNullOrEmpty(directoryName) && System.IO.File.Exists(directoryName)) && (!string.IsNullOrEmpty(commitParams.AppManifestPath) && System.IO.File.Exists(commitParams.AppManifestPath))) { byte[] bytes = ComponentVerifier.GenerateDigestValue(directoryName, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); byte[] buffer2 = ComponentVerifier.GenerateDigestValue(commitParams.AppManifestPath, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, System.Deployment.Internal.Isolation.Manifest.CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY); bool flag = false; Logger.AddInternalState("In-place update check. Existing manifest path = " + directoryName + ", Existing manifest hash=" + Encoding.UTF8.GetString(bytes) + ", New manifest path=" + commitParams.AppManifestPath + ", New manifest hash=" + Encoding.UTF8.GetString(buffer2)); if (bytes.Length == buffer2.Length) { int index = 0; while (index < bytes.Length) { if (bytes[index] != buffer2[index]) { break; } index++; } if (index >= bytes.Length) { flag = true; } } if (!flag) { throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ApplicationInplaceUpdate")); } } }
private void PatchFiles(SubscriptionState subState) { if (!subState.IsInstalled) { Logger.AddInternalState("Subscription is not installed. No patching."); } else { System.Deployment.Internal.Isolation.Store.IPathLock @lock = null; System.Deployment.Internal.Isolation.Store.IPathLock lock2 = null; using (subState.SubscriptionStore.AcquireSubscriptionReaderLock(subState)) { if (!subState.IsInstalled) { Logger.AddInternalState("Subscription is not installed. No patching."); return; } Hashtable hashtable = new Hashtable(); try { @lock = subState.SubscriptionStore.LockApplicationPath(subState.CurrentBind); AddFilesInHashtable(hashtable, subState.CurrentApplicationManifest, @lock.Path); try { if (subState.PreviousBind != null) { lock2 = subState.SubscriptionStore.LockApplicationPath(subState.PreviousBind); AddFilesInHashtable(hashtable, subState.PreviousApplicationManifest, lock2.Path); } Queue queue = new Queue(); do { DownloadQueueItem item = null; lock (this._fileQueue) { if (this._fileQueue.Count > 0) { item = (DownloadQueueItem)this._fileQueue.Dequeue(); } } if (item == null) { break; } if (!this.PatchSingleFile(item, hashtable)) { queue.Enqueue(item); } }while (!this._fCancelPending); lock (this._fileQueue) { while (this._fileQueue.Count > 0) { queue.Enqueue(this._fileQueue.Dequeue()); } this._fileQueue = queue; } } finally { if (lock2 != null) { lock2.Dispose(); } } } finally { if (@lock != null) { @lock.Dispose(); } } } if (this._fCancelPending) { throw new DownloadCancelledException(); } } }