internal static Task <long> GetBinaryResourcesModifiedTimeAsync(string fileName) { var pathToAssembly = CodePushUtils.GetAppFolder(); var pathToAssemblyResource = Path.Combine(pathToAssembly, CodePushConstants.AssetsBundlePrefix, fileName); var lastUpdateTime = File.GetCreationTime(pathToAssemblyResource); return(Task.FromResult(new DateTimeOffset(lastUpdateTime).ToUnixTimeMilliseconds())); }
public async Task <string> GetJavaScriptBundleFileAsync(string assetsBundleFileName) { AssetsBundleFileName = assetsBundleFileName; string binaryJsBundleUrl = CodePushUtils.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. CodePushUtils.LogBundleUrl(binaryJsBundleUrl); IsRunningBinaryVersion = true; return(binaryJsBundleUrl); } var packageMetadata = await UpdateManager.GetCurrentPackageAsync().ConfigureAwait(false); long?binaryModifiedDateDuringPackageInstall = null; var binaryModifiedDateDuringPackageInstallString = (string)packageMetadata[CodePushConstants.BinaryModifiedTimeKey]; if (binaryModifiedDateDuringPackageInstallString != null) { binaryModifiedDateDuringPackageInstall = long.Parse(binaryModifiedDateDuringPackageInstallString); } var packageAppVersion = (string)packageMetadata["appVersion"]; if (binaryModifiedDateDuringPackageInstall != null && binaryModifiedDateDuringPackageInstall == binaryResourcesModifiedTime && AppVersion.Equals(packageAppVersion)) { CodePushUtils.LogBundleUrl(packageFile.Path); IsRunningBinaryVersion = false; return(CodePushUtils.GetFileBundlePrefix() + packageFile.Path.Replace(CodePushUtils.GetAppFolder(), "").Replace("\\", "/")); } else { // The binary version is newer. DidUpdate = false; if (!MainPage.UseDeveloperSupport || !AppVersion.Equals(packageAppVersion)) { await ClearUpdatesAsync().ConfigureAwait(false); } CodePushUtils.LogBundleUrl(binaryJsBundleUrl); IsRunningBinaryVersion = true; return(binaryJsBundleUrl); } }
internal static async Task <IFolder> GetCodePushFolderAsync() { var pathToCodePush = Path.Combine(CodePushUtils.GetAppFolder(), CodePushConstants.CodePushFolderPrefix); return(await FileSystem.Current.LocalStorage.CreateFolderAsync(pathToCodePush, CreationCollisionOption.OpenIfExists).ConfigureAwait(false)); }