Beispiel #1
0
        public async Task Execute()
        {
            string tempPath   = DirectoryPatcher.GetTempPath(SubPath);
            string newPath    = DirectoryPatcher.PatchSource.GetSystemPath(PatchSubPath);
            string targetPath = DirectoryPatcher.GetTargetPath(SubPath);
            string backupPath = DirectoryPatcher.GetBackupPath(SubPath);

            // Ensure the temp directory exists, and decompress the file
            Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
            await DirectoryPatcher.FilePatcher.DecompressAsync(tempPath, newPath); // Extract to a temp location, so that after copying, swapping the old and new file is a quick operation (i.e. not likely to cause inconsistency when interrupted). Copying is also necessary because the file may be shared (moving is not allowed).

            // Get the old file out of the way, if it exists
            if (File.Exists(targetPath))
            {
                if (NeedsBackup)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(backupPath));
                    File.Move(targetPath, backupPath);
                }
                else
                {
                    File.Delete(targetPath);
                }
            }

            // Move the new file into place
            Directory.CreateDirectory(Path.GetDirectoryName(targetPath));
            File.Move(tempPath, targetPath);
        }
        public Task Execute()
        {
            string targetPath = _directoryPatcher.GetTargetPath(_subPath);
            string backupPath = _directoryPatcher.GetBackupPath(_subPath);

            Logger.Instance.Write($"RemoveAction - {targetPath} - {backupPath}");

            // Deletes or moves the file to backupPath, if it exists
            if (File.Exists(targetPath))
            {
                if (_needsBackup)
                {
                    // Backup file
                    Directory.CreateDirectory(Path.GetDirectoryName(backupPath));
                    File.Move(targetPath, backupPath);
                }
                else
                {
                    // Delete file
                    File.Delete(targetPath);
                }
            }

            // We're done; return CompletedTask
            return(TaskExtensions.CompletedTask);
        }
Beispiel #3
0
        public Task ExecuteAsync()
        {
            string targetPath = _directoryPatcher.GetTargetPath(_subPath);

            new FileInfo(targetPath).LastWriteTimeUtc = _lastWriteTime;
            return(TaskExtensions.CompletedTask);
        }
Beispiel #4
0
        public Task Execute()
        {
            string targetPath = DirectoryPatcher.GetTargetPath(SubPath);

            // Update LastWriteTime
            new FileInfo(targetPath).LastWriteTimeUtc = LastWriteTime;

            return(TaskExtensions.CompletedTask);
        }
Beispiel #5
0
        public async Task ExecuteAsync()
        {
            string tempPath   = DirectoryPatcher.GetTempPath(SubPath);
            string targetPath = DirectoryPatcher.GetTargetPath(SubPath);
            string patchPath  = DirectoryPatcher.PatchSource.GetSystemPath(PatchSubPath);

            Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
            await DirectoryPatcher.FilePatcher.ApplyPatchAsync(targetPath, tempPath, patchPath);

            File.Delete(targetPath);
            File.Move(tempPath, targetPath);
        }
Beispiel #6
0
        public async Task Execute()
        {
            string tempPath   = DirectoryPatcher.GetTempPath(SubPath);
            string targetPath = DirectoryPatcher.GetTargetPath(SubPath);
            string patchPath  = DirectoryPatcher.PatchSource.GetSystemPath(PatchSubPath);

            // Ensure the temp directory exists, and generate the new file based on the old file and the delta
            Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
            await DirectoryPatcher.FilePatcher.ApplyPatchAsync(targetPath, tempPath, patchPath);

            // Delete the old file and move the new one into place
            File.Delete(targetPath);
            File.Move(tempPath, targetPath);
        }
        public Task Execute()
        {
            string targetPath = _directoryPatcher.GetTargetPath(_subPath);

            Logger.Instance.Write($"ModifiedTimeReplaceAction - {targetPath} - {_lastWriteTime.ToString(CultureInfo.InvariantCulture)}");

            // Update LastWriteTime
            try
            {
                new FileInfo(targetPath).LastWriteTimeUtc = _lastWriteTime;
            }
            catch (Exception ex)
            {
                Logger.Instance.Write($"ModifiedTimeReplaceAction encountered an error\r\n{ex.Message}\r\nStack Trace:\r\n{ex.StackTrace}");
            }

            return(TaskExtensions.CompletedTask);
        }
Beispiel #8
0
        public Task ExecuteAsync()
        {
            string targetPath = _directoryPatcher.GetTargetPath(_subPath);
            string backupPath = _directoryPatcher.GetBackupPath(_subPath);

            if (File.Exists(targetPath))
            {
                if (_needsBackup)
                {
                    Directory.CreateDirectory(Path.GetDirectoryName(backupPath));
                    File.Move(targetPath, backupPath);
                }
                else
                {
                    File.Delete(targetPath);
                }
            }
            return(TaskExtensions.CompletedTask);
        }
Beispiel #9
0
        public Task Execute()
        {
            string targetPath = DirectoryPatcher.GetTargetPath(SubPath);
            string backupPath = DirectoryPatcher.GetBackupPath(SubPath);

            // Deletes or moves the file to backupPath, if it exists
            if (File.Exists(targetPath))
            {
                if (NeedsBackup)
                {
                    // Backup file
                    Directory.CreateDirectory(Path.GetDirectoryName(backupPath));
                    File.Move(targetPath, backupPath);
                }
                else
                {
                    // Delete file
                    File.Delete(targetPath);
                }
            }

            // We're done; return CompletedTask
            return(TaskExtensions.CompletedTask);
        }