Beispiel #1
0
        public async Task <string> GetJavaScriptBundleFileAsync(string assetsBundleFileName)
        {
            AssetsBundleFileName = assetsBundleFileName;
            string binaryJsBundleUrl = GreatPushUtils.GetAssetsBundlePrefix() + assetsBundleFileName;

            var binaryResourcesModifiedTime = await FileUtils.GetBinaryResourcesModifiedTimeAsync(AssetsBundleFileName).ConfigureAwait(false);

            var packageFile = await UpdateManager.GetCurrentPackageBundleAsync(AssetsBundleFileName).ConfigureAwait(false);

            if (packageFile == null)
            {
                // There has not been any downloaded updates.
                GreatPushUtils.LogBundleUrl(binaryJsBundleUrl);
                IsRunningBinaryVersion = true;
                return(binaryJsBundleUrl);
            }

            var packageMetadata = await UpdateManager.GetCurrentPackageAsync().ConfigureAwait(false);

            long?binaryModifiedDateDuringPackageInstall       = null;
            var  binaryModifiedDateDuringPackageInstallString = (string)packageMetadata[GreatPushConstants.BinaryModifiedTimeKey];

            if (binaryModifiedDateDuringPackageInstallString != null)
            {
                binaryModifiedDateDuringPackageInstall = long.Parse(binaryModifiedDateDuringPackageInstallString);
            }

            var packageAppVersion = (string)packageMetadata["appVersion"];

            if (binaryModifiedDateDuringPackageInstall != null &&
                binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime &&
                AppVersion.Equals(packageAppVersion))
            {
                GreatPushUtils.LogBundleUrl(packageFile.Path);
                IsRunningBinaryVersion = false;

                return(GreatPushUtils.GetFileBundlePrefix() + GreatPushUtils.ExtractSubFolder(packageFile.Path));
            }
            else
            {
                // The binary version is newer.
                DidUpdate = false;
                if (!UseDeveloperSupport || !AppVersion.Equals(packageAppVersion))
                {
                    await ClearUpdatesAsync().ConfigureAwait(false);
                }

                GreatPushUtils.LogBundleUrl(binaryJsBundleUrl);
                IsRunningBinaryVersion = true;
                return(binaryJsBundleUrl);
            }
        }
        internal static async Task <IFolder> GetGreatPushFolderAsync()
        {
            var pathToGreatPush = Path.Combine(GreatPushUtils.GetFileBundlePrefix(), GreatPushConstants.GreatPushFolderPrefix);

            return(await FileSystem.Current.LocalStorage.CreateFolderAsync(pathToGreatPush, CreationCollisionOption.OpenIfExists).ConfigureAwait(false));
        }