private Pack1Unarchiver(string packagePath, Pack1Meta metaData, string destinationDirPath, byte[] key, string suffix, BytesRange range) { Checks.ArgumentFileExists(packagePath, "packagePath"); Checks.ArgumentDirectoryExists(destinationDirPath, "destinationDirPath"); Checks.ArgumentNotNull(suffix, "suffix"); if (range.Start == 0) { Assert.AreEqual(MagicBytes.Pack1, MagicBytes.ReadFileType(packagePath), "Is not Pack1 format"); } DebugLogger.LogConstructor(); DebugLogger.LogVariable(packagePath, "packagePath"); DebugLogger.LogVariable(destinationDirPath, "destinationDirPath"); DebugLogger.LogVariable(suffix, "suffix"); _packagePath = packagePath; _metaData = metaData; _destinationDirPath = destinationDirPath; _suffix = suffix; _range = range; using (var sha256 = SHA256.Create()) { _key = sha256.ComputeHash(key); } _iv = Convert.FromBase64String(_metaData.Iv); }
public override void Prepare(IStatusMonitor statusMonitor) { base.Prepare(statusMonitor); Checks.ArgumentNotNull(statusMonitor, "statusMonitor"); DebugLogger.Log("Preparing diff installation."); _localData.PrepareForWriting(); _temporaryData.PrepareForWriting(); double unarchivePackageWeight = StatusWeightHelper.GetUnarchivePackageWeight(_versionDiffSummary.Size); _unarchivePackageStatusReporter = statusMonitor.CreateGeneralStatusReporter(unarchivePackageWeight); double addFilesWeight = StatusWeightHelper.GetAddDiffFilesWeight(_versionDiffSummary); _addFilesStatusReporter = statusMonitor.CreateGeneralStatusReporter(addFilesWeight); double modifiedFilesWeight = StatusWeightHelper.GetModifyDiffFilesWeight(_versionDiffSummary); _modifiedFilesStatusReporter = statusMonitor.CreateGeneralStatusReporter(modifiedFilesWeight); double removeFilesWeight = StatusWeightHelper.GetRemoveDiffFilesWeight(_versionDiffSummary); _removeFilesStatusReporter = statusMonitor.CreateGeneralStatusReporter(removeFilesWeight); }
public CheckDiskSpaceCommand(AppContentSummary contentSummary, string localDirectoryPath) { Checks.ArgumentNotNull(localDirectoryPath, "localDirectoryPath"); _contentSummary = contentSummary; _localDirectoryPath = localDirectoryPath; }
public AppUpdaterDiffStrategy(AppUpdaterContext context) { DebugLogger.LogConstructor(); Checks.ArgumentNotNull(context, "context"); _context = context; }
public GeneralStatusReporter(GeneralStatusHolder generalStatusHolder) { Checks.ArgumentNotNull(generalStatusHolder, "generalStatusHolder"); _generalStatusHolder = generalStatusHolder; _generalStatusHolder.Progress = 0.0; }
public CheckDiskSpaceCommand(AppDiffSummary diffSummary, string localDirectoryPath, long bigestFileSize) { Checks.ArgumentNotNull(localDirectoryPath, "localDirectoryPath"); _diffSummary = diffSummary; _localDirectoryPath = localDirectoryPath; _bigestFileSize = bigestFileSize; }
public AppUpdater(AppUpdaterContext context) { Checks.ArgumentNotNull(context, "context"); DebugLogger.LogConstructor(); _strategyResolver = new AppUpdaterStrategyResolver(); Context = context; }
public AppUpdaterContext(App app, AppUpdaterConfiguration configuration, ILicenseDialog licenseDialog) { Checks.ArgumentNotNull(app, "app"); Checks.ArgumentNotNull(licenseDialog, "licenseDialog"); App = app; Configuration = configuration; LicenseDialog = licenseDialog; }
public AppStarter(App app) { Checks.ArgumentNotNull(app, "app"); DebugLogger.LogConstructor(); _app = app; AppFinder = new AppFinder(); }
public AppUpdaterContentStrategy(AppUpdaterContext context, UpdaterStatus status) { Checks.ArgumentNotNull(context, "context"); DebugLogger.LogConstructor(); _context = context; _status = status; }
public UninstallCommand(ILocalDirectory localData, ILocalMetaData localMetaData) { Checks.ArgumentNotNull(localData, "localData"); Checks.ArgumentNotNull(localMetaData, "localMetaData"); DebugLogger.LogConstructor(); _localData = localData; _localMetaData = localMetaData; }
public AppUpdaterContext(App app, AppUpdaterConfiguration configuration, IStatusMonitor statusMonitor, ILicenseDialog licenseDialog) { Checks.ArgumentNotNull(app, "app"); Checks.ArgumentNotNull(statusMonitor, "statusMonitor"); Checks.ArgumentNotNull(licenseDialog, "licenseDialog"); App = app; Configuration = configuration; StatusMonitor = statusMonitor; LicenseDialog = licenseDialog; }
/// <summary> /// Executes the command and returns the result. /// </summary> public JToken ExecuteCommand(string command) { Checks.ArgumentNotNull(command, "command"); DebugLogger.Log(string.Format("Executing command {0}", command)); WriteCommand(command); string resultStr = ReadCommandResult(); return(ParseCommandResult(resultStr)); }
public RemoteData(string appSecret, MainApiConnection mainApiConnection) { Checks.ArgumentNotNullOrEmpty(appSecret, "appSecret"); Checks.ArgumentNotNull(mainApiConnection, "mainApiConnection"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(appSecret, "appSecret"); _appSecret = appSecret; _mainApiConnection = mainApiConnection; }
public AppRepairer(AppUpdaterContext context, UpdaterStatus status) { DebugLogger.LogConstructor(); Checks.ArgumentNotNull(context, "context"); Context = context; _status = status; _strategyResolver = new AppUpdaterStrategyResolver(_status); _commandFactory = new AppUpdaterCommandFactory(); }
public override void Prepare(IStatusMonitor statusMonitor) { base.Prepare(statusMonitor); Checks.ArgumentNotNull(statusMonitor, "statusMonitor"); DebugLogger.Log("Preparing package download."); double weight = StatusWeightHelper.GetResourceDownloadWeight(_resource); _statusReporter = statusMonitor.CreateDownloadStatusReporter(weight); }
public ValidateLicenseCommand(ILicenseDialog licenseDialog, IRemoteMetaData remoteMetaData, ICache cache) { Checks.ArgumentNotNull(licenseDialog, "licenseDialog"); Checks.ArgumentNotNull(remoteMetaData, "remoteMetaData"); Checks.ArgumentNotNull(cache, "cache"); DebugLogger.LogConstructor(); _licenseDialog = licenseDialog; _remoteMetaData = remoteMetaData; _cache = cache; }
public override void Prepare(IStatusMonitor statusMonitor) { base.Prepare(statusMonitor); Checks.ArgumentNotNull(statusMonitor, "statusMonitor"); DebugLogger.Log("Preparing version integrity check."); double weight = StatusWeightHelper.GetCheckVersionIntegrityWeight(_versionSummary); _statusReporter = statusMonitor.CreateGeneralStatusReporter(weight); }
public ChunkedFileStream(string path, long fileSize, ChunksData chunksData, HashFunction hashFunction, WorkFlags workFlags = WorkFlags.None) { Checks.ArgumentNotNullOrEmpty(path, "path"); Checks.ArgumentMoreThanZero(fileSize, "fileSize"); Checks.ArgumentNotNull(hashFunction, "hashFunction"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(path, "path"); DebugLogger.LogVariable(fileSize, "fileSize"); _fileSize = fileSize; _chunksData = chunksData; _hashFunction = hashFunction; _buffer = new byte[_chunksData.ChunkSize]; if ((workFlags | WorkFlags.PreservePreviousFile) != 0) { // Often you may want to continue downloading of a file if this exists // It tries to open a file and re-download it from the verified position. // It does not check the hash of the file. It trusts that the file is already valid up to that point. // Because the only way to download the file should be using Chunked Downloader. _fileStream = new FileStream(path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.None); _fileStream.Seek(0, SeekOrigin.End); // seek and stay at the end, so we can append long currentFileSize = _fileStream.Position; // Let's make sure that file size is a multiply of chunk size. // If not, something is wrong with the file. if (currentFileSize % chunksData.ChunkSize == 0) { _chunkIndex = (int)(currentFileSize / chunksData.ChunkSize); } else { DebugLogger.LogWarningFormat( "File {0} size {1} is not a multiply of chunk size: {2}. Will recreate it.", path, currentFileSize, chunksData.ChunkSize); _fileStream.Close(); _fileStream.Dispose(); _fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); } } else { _fileStream = new FileStream(path, FileMode.Create, FileAccess.Write, FileShare.None); } }
public override void Prepare(IStatusMonitor statusMonitor) { base.Prepare(statusMonitor); Checks.ArgumentNotNull(statusMonitor, "statusMonitor"); DebugLogger.Log("Preparing uninstallation."); _localData.PrepareForWriting(); double weight = StatusWeightHelper.GetUninstallWeight(); _statusReporter = statusMonitor.CreateGeneralStatusReporter(weight); }
public override void Prepare(UpdaterStatus status) { base.Prepare(status); Checks.ArgumentNotNull(status, "statusMonitor"); DebugLogger.Log("Preparing version integrity check."); _status = new OperationStatus { Weight = { Value = StatusWeightHelper.GetCheckVersionIntegrityWeight(_versionSummary) }, Description = { Value = "Checking version integrity..." } }; status.RegisterOperation(_status); }
public override void Prepare(UpdaterStatus status, CancellationToken cancellationToken) { base.Prepare(status, cancellationToken); Checks.ArgumentNotNull(status, "statusMonitor"); DebugLogger.Log("Preparing uninstallation."); _localData.PrepareForWriting(); _statusReporter = new OperationStatus { Weight = { Value = StatusWeightHelper.GetUninstallWeight() } }; status.RegisterOperation(_statusReporter); }
public CheckVersionIntegrityCommand(int versionId, AppContentSummary versionSummary, ILocalDirectory localDirectory, ILocalMetaData localMetaData) { Checks.ArgumentValidVersionId(versionId, "versionId"); // TODO: Validate the content summary. Checks.ArgumentNotNull(localDirectory, "localDirectory"); Checks.ArgumentNotNull(localMetaData, "localMetaData"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(versionId, "versionId"); _versionId = versionId; _versionSummary = versionSummary; _localDirectory = localDirectory; _localMetaData = localMetaData; }
public HttpDownloader(string destinationFilePath, string[] mirrorUrls, long size, int timeout) { Checks.ArgumentParentDirectoryExists(destinationFilePath, "destinationFilePath"); Checks.ArgumentMoreThanZero(timeout, "timeout"); Checks.ArgumentNotNull(mirrorUrls, "mirrorUrls"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(destinationFilePath, "destinationFilePath"); DebugLogger.LogVariable(mirrorUrls, "mirrorUrls"); DebugLogger.LogVariable(size, "size"); DebugLogger.LogVariable(timeout, "timeout"); _destinationFilePath = destinationFilePath; _mirrorUrls = mirrorUrls; _size = size; _timeout = timeout; }
public CheckVersionIntegrityCommand(int versionId, AppContentSummary versionSummary, ILocalDirectory localDirectory, ILocalMetaData localMetaData, bool isCheckingHash, bool isCheckingSize) { Checks.ArgumentValidVersionId(versionId, "versionId"); Checks.ArgumentNotNull(versionSummary, "versionSummary"); Checks.ArgumentNotNull(localDirectory, "localDirectory"); Checks.ArgumentNotNull(localMetaData, "localMetaData"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(versionId, "versionId"); _versionId = versionId; _versionSummary = versionSummary; _localDirectory = localDirectory; _localMetaData = localMetaData; _isCheckingSize = isCheckingSize; _isCheckingHash = isCheckingHash; }
public override void Prepare(IStatusMonitor statusMonitor) { base.Prepare(statusMonitor); Checks.ArgumentNotNull(statusMonitor, "statusMonitor"); DebugLogger.Log("Preparing content installation."); _localData.PrepareForWriting(); _temporaryData.PrepareForWriting(); double copyFilesWeight = StatusWeightHelper.GetCopyContentFilesWeight(_versionContentSummary); _copyFilesStatusReporter = statusMonitor.CreateGeneralStatusReporter(copyFilesWeight); double unarchivePackageWeight = StatusWeightHelper.GetUnarchivePackageWeight(_versionContentSummary.Size); _unarchivePackageStatusReporter = statusMonitor.CreateGeneralStatusReporter(unarchivePackageWeight); }
public App(ILocalDirectory localDirectory, ILocalMetaData localMetaData, ITemporaryDirectory temporaryDirectory, IDownloadDirectory downloadDirectory, IRemoteData remoteData, IRemoteMetaData remoteMetaData, int overrideLatestVersionId) { Checks.ArgumentNotNull(localDirectory, "localData"); Checks.ArgumentNotNull(localMetaData, "localMetaData"); Checks.ArgumentNotNull(temporaryDirectory, "temporaryData"); Checks.ArgumentNotNull(downloadDirectory, "downloadData"); Checks.ArgumentNotNull(remoteData, "remoteData"); Checks.ArgumentNotNull(remoteMetaData, "remoteMetaData"); LocalDirectory = localDirectory; LocalMetaData = localMetaData; TemporaryDirectory = temporaryDirectory; DownloadDirectory = downloadDirectory; RemoteData = remoteData; RemoteMetaData = remoteMetaData; _overrideLatestVersionId = overrideLatestVersionId; }
public InstallDiffCommand(string packagePath, string packageMetaPath, string packagePassword, int versionId, AppDiffSummary versionDiffSummary, ILocalDirectory localData, ILocalMetaData localMetaData, ITemporaryDirectory temporaryData) { Checks.ArgumentValidVersionId(versionId, "versionId"); // TODO: Check whether version diff summary is correct Checks.ArgumentNotNull(localData, "localData"); Checks.ArgumentNotNull(localMetaData, "localMetaData"); Checks.ArgumentNotNull(temporaryData, "temporaryData"); _packagePath = packagePath; _packageMetaPath = packageMetaPath; _packagePassword = packagePassword; _versionId = versionId; _versionDiffSummary = versionDiffSummary; _localData = localData; _localMetaData = localMetaData; _temporaryData = temporaryData; }
public static void Invoke(Action action, Action onSucessAction = null, Action <Exception> onFailedAction = null) { Checks.ArgumentNotNull(action, "action"); try { action(); } catch (Exception exception) { if (onFailedAction != null) { onFailedAction(exception); } } if (onSucessAction != null) { onSucessAction(); } }
public InstallContentCommand(string packagePath, string packageMetaPath, string packagePassword, int versionId, AppContentSummary versionContentSummary, ILocalDirectory localData, ILocalMetaData localMetaData) { Checks.ArgumentValidVersionId(versionId, "versionId"); // TODO: Validate the content summary. Checks.ArgumentNotNull(localData, "localData"); Checks.ArgumentNotNull(localMetaData, "localMetaData"); DebugLogger.LogConstructor(); DebugLogger.LogVariable(packagePath, "packagePath"); DebugLogger.LogVariable(versionId, "versionId"); _packagePath = packagePath; _packageMetaPath = packageMetaPath; _packagePassword = packagePassword; _versionId = versionId; _versionContentSummary = versionContentSummary; _localData = localData; _localMetaData = localMetaData; }