Пример #1
0
        private void CheckApplicationPayload(CommitApplicationParams commitParams)
        {
            if (commitParams.AppGroup == null && commitParams.appType != AppType.CustomHostSpecified)
            {
                string path = Path.Combine(commitParams.AppPayloadPath, commitParams.AppManifest.EntryPoints[0].CommandFile);
                if (!PlatformDetector.IsWin8orLater())
                {
                    SystemUtils.CheckSupportedImageAndCLRVersions(path);
                }
            }
            string str = (string)null;

            Store.IPathLock pathLock = (Store.IPathLock)null;
            try
            {
                pathLock = this._compStore.LockAssemblyPath(commitParams.AppManifest.Identity);
                str      = Path.GetDirectoryName(pathLock.Path);
                str      = Path.Combine(str, "manifests");
                str      = Path.Combine(str, Path.GetFileName(pathLock.Path) + ".manifest");
            }
            catch (DeploymentException ex)
            {
            }
            catch (COMException ex)
            {
            }
            finally
            {
                if (pathLock != null)
                {
                    pathLock.Dispose();
                }
            }
            if (string.IsNullOrEmpty(str) || !System.IO.File.Exists(str) || (string.IsNullOrEmpty(commitParams.AppManifestPath) || !System.IO.File.Exists(commitParams.AppManifestPath)))
            {
                return;
            }
            byte[] digestValue1 = ComponentVerifier.GenerateDigestValue(str, CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            byte[] digestValue2 = ComponentVerifier.GenerateDigestValue(commitParams.AppManifestPath, CMS_HASH_DIGESTMETHOD.CMS_HASH_DIGESTMETHOD_SHA1, CMS_HASH_TRANSFORM.CMS_HASH_TRANSFORM_IDENTITY);
            bool   flag         = false;

            Logger.AddInternalState("In-place update check. Existing manifest path = " + str + ", Existing manifest hash=" + Encoding.UTF8.GetString(digestValue1) + ", New manifest path=" + commitParams.AppManifestPath + ", New manifest hash=" + Encoding.UTF8.GetString(digestValue2));
            if (digestValue1.Length == digestValue2.Length)
            {
                int index = 0;
                while (index < digestValue1.Length && (int)digestValue1[index] == (int)digestValue2[index])
                {
                    ++index;
                }
                if (index >= digestValue1.Length)
                {
                    flag = true;
                }
            }
            if (!flag)
            {
                throw new DeploymentException(ExceptionTypes.Subscription, Resources.GetString("Ex_ApplicationInplaceUpdate"));
            }
        }
Пример #2
0
 private void PatchFiles(SubscriptionState subState)
 {
     if (!subState.IsInstalled)
     {
         Logger.AddInternalState("Subscription is not installed. No patching.");
     }
     else
     {
         Store.IPathLock pathLock1 = (Store.IPathLock)null;
         Store.IPathLock pathLock2 = (Store.IPathLock)null;
         using (subState.SubscriptionStore.AcquireSubscriptionReaderLock(subState))
         {
             if (!subState.IsInstalled)
             {
                 Logger.AddInternalState("Subscription is not installed. No patching.");
                 return;
             }
             Hashtable hashtable = new Hashtable();
             try
             {
                 pathLock1 = subState.SubscriptionStore.LockApplicationPath(subState.CurrentBind);
                 FileDownloader.AddFilesInHashtable(hashtable, subState.CurrentApplicationManifest, pathLock1.Path);
                 try
                 {
                     if (subState.PreviousBind != null)
                     {
                         pathLock2 = subState.SubscriptionStore.LockApplicationPath(subState.PreviousBind);
                         FileDownloader.AddFilesInHashtable(hashtable, subState.PreviousApplicationManifest, pathLock2.Path);
                     }
                     Queue queue = new Queue();
                     do
                     {
                         FileDownloader.DownloadQueueItem downloadQueueItem = (FileDownloader.DownloadQueueItem)null;
                         lock (this._fileQueue)
                         {
                             if (this._fileQueue.Count > 0)
                             {
                                 downloadQueueItem = (FileDownloader.DownloadQueueItem) this._fileQueue.Dequeue();
                             }
                         }
                         if (downloadQueueItem != null)
                         {
                             if (!this.PatchSingleFile(downloadQueueItem, hashtable))
                             {
                                 queue.Enqueue((object)downloadQueueItem);
                             }
                         }
                         else
                         {
                             break;
                         }
                     }while (!this._fCancelPending);
                     lock (this._fileQueue)
                     {
                         while (this._fileQueue.Count > 0)
                         {
                             queue.Enqueue(this._fileQueue.Dequeue());
                         }
                         this._fileQueue = queue;
                     }
                 }
                 finally
                 {
                     if (pathLock2 != null)
                     {
                         pathLock2.Dispose();
                     }
                 }
             }
             finally
             {
                 if (pathLock1 != null)
                 {
                     pathLock1.Dispose();
                 }
             }
         }
         if (this._fCancelPending)
         {
             throw new DownloadCancelledException();
         }
     }
 }