示例#1
0
        public override void Prepare([NotNull] UpdaterStatus status, CancellationToken cancellationToken)
        {
            if (status == null)
            {
                throw new ArgumentNullException("status");
            }

            try
            {
                _logger.LogDebug("Preparing diff installation...");

                base.Prepare(status, cancellationToken);

                _localData.PrepareForWriting();

                _previousContentSummary = _remoteMetaData.GetContentSummary(_versionId - 1, cancellationToken);
                _contentSummary         = _remoteMetaData.GetContentSummary(_versionId, cancellationToken);
                _diffSummary            = _remoteMetaData.GetDiffSummary(_versionId, cancellationToken);

                double unarchivePackageWeight = StatusWeightHelper.GetUnarchivePackageWeight(_diffSummary.Size);
                _logger.LogTrace("unarchivePackageWeight = " + unarchivePackageWeight);
                _unarchivePackageStatusReporter = new OperationStatus
                {
                    Weight = { Value = unarchivePackageWeight }
                };
                status.RegisterOperation(_unarchivePackageStatusReporter);

                double addFilesWeight = StatusWeightHelper.GetAddDiffFilesWeight(_diffSummary);
                _logger.LogTrace("addFilesWeight = " + addFilesWeight);
                _addFilesStatusReporter = new OperationStatus
                {
                    Weight = { Value = addFilesWeight }
                };
                status.RegisterOperation(_addFilesStatusReporter);

                double modifiedFilesWeight = StatusWeightHelper.GetModifyDiffFilesWeight(_diffSummary);
                _logger.LogTrace("modifiedFilesWeight = " + modifiedFilesWeight);
                _modifiedFilesStatusReporter = new OperationStatus
                {
                    Weight = { Value = modifiedFilesWeight }
                };
                status.RegisterOperation(_modifiedFilesStatusReporter);

                double removeFilesWeight = StatusWeightHelper.GetRemoveDiffFilesWeight(_diffSummary);
                _logger.LogTrace("removeFilesWeight = " + removeFilesWeight);
                _removeFilesStatusReporter = new OperationStatus
                {
                    Weight = { Value = removeFilesWeight }
                };
                status.RegisterOperation(_removeFilesStatusReporter);

                _logger.LogDebug("Diff installation prepared.");
            }
            catch (Exception e)
            {
                _logger.LogError("Failed to prepare diff installation.", e);
                throw;
            }
        }
示例#2
0
        public CheckDiskSpaceCommand(AppDiffSummary diffSummary, string localDirectoryPath, long bigestFileSize)
        {
            Checks.ArgumentNotNull(localDirectoryPath, "localDirectoryPath");

            _diffSummary        = diffSummary;
            _localDirectoryPath = localDirectoryPath;
            _bigestFileSize     = bigestFileSize;
        }
示例#3
0
        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 ICheckDiskSpace CreateCheckDiskSpaceCommandForDiff(int versionId, AppUpdaterContext context)
        {
            // get project biggest file size
            long biggestFileSize = 0;

            string[] registeredEntries = context.App.LocalMetaData.GetRegisteredEntries();
            foreach (string entry in registeredEntries)
            {
                string filePath = context.App.LocalDirectory.Path.PathCombine(entry);
                var    fileInfo = new FileInfo(filePath);
                if (fileInfo.Exists && fileInfo.Length > biggestFileSize)
                {
                    biggestFileSize = fileInfo.Length;
                }
            }

            AppDiffSummary diffSummary = context.App.RemoteMetaData.GetDiffSummary(versionId);

            return(new CheckDiskSpaceCommand(diffSummary, context.App.LocalDirectory.Path, biggestFileSize));
        }
 public static double GetRemoveDiffFilesWeight(AppDiffSummary summary)
 {
     return(BytesToWeight(summary.Size) * 0.001);
 }
 public static double GetModifyDiffFilesWeight(AppDiffSummary summary)
 {
     return(BytesToWeight(summary.Size) * 0.2);
 }