DeleteFileTask

1. Overview

The DeleteFileTask module provides tracked filesystem deletion for BastionGuard Backup. It implements an AsyncTask that deletes snapshot trees with RSYNC or recursive removal while parsing progress information for the UI and console.

The implementation is written in Vala and uses GLib/GIO together with the application utility namespaces required by the file.


2. Dependencies and Integration

The module imports:

  • TeeJee.Logging
  • TeeJee.FileSystem
  • TeeJee.JsonHelper
  • TeeJee.ProcessHelper
  • TeeJee.System
  • TeeJee.Misc

Key runtime integrations include:

  • Gee – typed lists, maps, queues, or collection operations

3. Declared Types

3.1 DeleteFileTask

public class DeleteFileTask : AsyncTask

This class encapsulates the state and operations described by this source file.


4. State, Properties, Constants, and Signals

Public and protected state

  • public string dest_path – Filesystem-related value used for dest path.
  • public bool verbose – Boolean state controlling or reporting verbose.
  • public bool io_nice – Boolean state controlling or reporting io nice.
  • public bool use_rsync – Boolean state controlling or reporting use rsync.
  • public int64 status_line_count – Counter associated with status line count.
  • public int64 total_size – Size or capacity value associated with total size.
  • public string status_message – Human-readable text used for status message.
  • public string time_remaining – Runtime state used by the module.

Internal state

  • private string source_path – Filesystem-related value used for source path.
  • private Gee.HashMap<string, Regex> regex_list – Collection used to store regex list.

5. Public API and Operational Methods

5.1 DeleteFileTask()

public DeleteFileTask()

Initializes the object state, allocates required collections or widgets, and applies constructor parameters.

5.2 prepare()

public override void prepare()

Implements the prepare operation for this module.

5.3 build_script()

protected override string build_script()

Generates either an RSYNC deletion command against an empty directory or a recursive removal command, with optional I/O priority reduction.

  • Performs filesystem access and handles files or directories through GLib or TeeJee helpers.

5.4 parse_stdout_line()

public override void parse_stdout_line(string out_line)

Parses stdout line and updates structured runtime data.

5.5 parse_stderr_line()

public override void parse_stderr_line(string err_line)

Parses stderr line and updates structured runtime data.

5.6 update_progress_parse_console_output()

public bool update_progress_parse_console_output (string line)

Implements the update progress parse console output operation for this module.

  • Uses regular expressions to parse or validate text output.

6. Internal Helpers

6.1 init_regular_expressions()

private void init_regular_expressions()

Initializes regular expressions and prepares it for use.


7. Filesystem Paths and Resource Locations

The source references the following absolute or template paths:

/tmp/%s_empty

Some values are templates completed at runtime with application names, process IDs, device identifiers, or file names.


8. External Commands and System Interfaces

The module constructs, checks, or parses commands containing:

ionice -c2 -n7 
matched: rsync-deleted:%s
rm -rf
rsync -aii
rsync-deleted

Execution success is determined from command exit status and, where applicable, parsed standard output or standard error.


9. Operational Flow

  1. Initialize object state, widgets, regular expressions, paths, or generated scripts.
  2. Transform raw values, command output, or metadata into structured or display-ready form.

10. Error Handling and Diagnostics

  • GLib and filesystem exceptions are caught locally in the operations that can fail.
  • The TeeJee logging layer records errors, debug state, generated commands, and operational messages.

11. Runtime and Security Considerations

  • Output parsing: parsers depend on stable external-command or system-file formats and should be tested across distributions.

12. Licensing

The source is distributed under the GNU General Public License version 2 or any later version.

The source header identifies:

Copyright 2012-2018 Tony George &lt;teejeetech@gmail.com&gt;