Esempio n. 1
0
        private void EmplaceFile(string source, string target, CancellationToken cancellationToken)
        {
            _logger.LogDebug(string.Format("Installing file {0} into {1}", source, target));

            if (!File.Exists(source))
            {
                throw new Exception(string.Format("Source file {0} doesn't exist.", source));
            }

            DirectoryOperations.CreateParentDirectory(target, cancellationToken);

            if (File.Exists(target))
            {
                FileOperations.Delete(target, cancellationToken);
            }

            FileOperations.Move(source, target, cancellationToken);
        }
Esempio n. 2
0
        private void ProcessAddedFiles(string packageDirPath, string suffix,
                                       CancellationToken cancellationToken)
        {
            DebugLogger.Log("Processing added files.");

            _addFilesStatusReporter.OnProgressChanged(0.0, "Installing package...");

            for (int i = 0; i < _versionDiffSummary.AddedFiles.Length; i++)
            {
                cancellationToken.ThrowIfCancellationRequested();

                var entryName = _versionDiffSummary.AddedFiles[i];

                string entryPath = _localData.Path.PathCombine(entryName);

                if (entryName.EndsWith("/"))
                {
                    DirectoryOperations.CreateDirectory(entryPath);

                    // TODO: Uncomment this after fixing directory registration in install content command
                    //_localMetaData.RegisterEntry(entryName, _versionId);
                }
                else
                {
                    string sourceFilePath = Path.Combine(packageDirPath, entryName + suffix);

                    if (!File.Exists(sourceFilePath))
                    {
                        throw new InstallerException(string.Format("Cannot find file <{0}> in content package.", entryName));
                    }

                    DebugLogger.LogFormat("Copying {0} -> {1}", sourceFilePath, entryName);
                    DirectoryOperations.CreateParentDirectory(entryPath);
                    FileOperations.Copy(sourceFilePath, entryPath, true);

                    _localMetaData.RegisterEntry(entryName, _versionId);
                }

                _addFilesStatusReporter.OnProgressChanged((i + 1) / (double)_versionDiffSummary.AddedFiles.Length, "Installing package...");
            }

            _addFilesStatusReporter.OnProgressChanged(1.0, "Installing package...");
        }
        private void InstallFile(SourceFile sourceFile, CancellationToken cancellationToken)
        {
            DebugLogger.Log(string.Format("Installing file {0}", sourceFile.Name));

            if (!sourceFile.Exists())
            {
                throw new InstallerException(string.Format("Cannot find file {0} in content package.", sourceFile.Name));
            }

            string destinationFilePath = _localData.Path.PathCombine(sourceFile.Name);

            DirectoryOperations.CreateParentDirectory(destinationFilePath, cancellationToken);

            if (File.Exists(destinationFilePath))
            {
                DebugLogger.LogFormat("Destination file {0} already exists, removing it.", destinationFilePath);
                FileOperations.Delete(destinationFilePath, cancellationToken);
            }

            FileOperations.Move(sourceFile.FullPath, destinationFilePath, cancellationToken);
            _localMetaData.RegisterEntry(sourceFile.Name, _versionId);
        }
        private void InstallFile(string fileName, string packageDirPath, string suffix)
        {
            DebugLogger.Log(string.Format("Installing file {0}", fileName + suffix));

            string sourceFilePath = Path.Combine(packageDirPath, fileName + suffix);

            if (!File.Exists(sourceFilePath))
            {
                throw new InstallerException(string.Format("Cannot find file {0} in content package.", fileName));
            }

            string destinationFilePath = _localData.Path.PathCombine(fileName);

            DirectoryOperations.CreateParentDirectory(destinationFilePath);

            if (File.Exists(destinationFilePath))
            {
                DebugLogger.LogFormat("Destination file {0} already exists, removing it.", destinationFilePath);
                FileOperations.Delete(destinationFilePath);
            }

            FileOperations.Move(sourceFilePath, destinationFilePath);
            _localMetaData.RegisterEntry(fileName, _versionId);
        }