Skip to content
API Documentation
BastionGuard™
RsyncSpaceCheckTask Class Reference
Inheritance diagram for RsyncSpaceCheckTask:
AsyncTask

Public Member Functions

 RsyncSpaceCheckTask ()
override void prepare ()
override void parse_stdout_line (string out_line)
override void parse_stderr_line (string err_line)
bool update_progress_parse_console_output (string line)
Public Member Functions inherited from AsyncTask
signal void stdout_line_read (string line)
signal void stderr_line_read (string line)
signal void task_complete ()
void write_stdin (string line)
virtual void execute ()
bool is_running ()
void stop (AppStatus status_to_update=AppStatus.CANCELLED)
void pause (AppStatus status_to_update=AppStatus.PAUSED)
void resume (AppStatus status_to_update=AppStatus.RUNNING)
void print_app_status ()

Public Attributes

bool delete_extra = true
bool delete_after = false
bool delete_excluded = false
bool relative = false
string exclude_from_file = ""
string link_from_path = ""
string source_path = ""
string dest_path = ""
bool verbose = true
bool io_nice = true
bool dry_run = false
int64 status_line_count = 0
int64 total_size = 0
Public Attributes inherited from AsyncTask
AppStatus status = AppStatus.NOT_STARTED
GLib.Mutex status_line_mutex
int exit_code = 0
GLib.Timer timer
double progress = 0.0
double percent = 0.0
int64 prg_count = 0
int64 prg_count_total = 0

Protected Member Functions

override string build_script ()
Protected Member Functions inherited from AsyncTask
 AsyncTask ()
string build_script ()
virtual bool begin ()
void parse_stdout_line (string out_line)
void parse_stderr_line (string err_line)
virtual void finish_task ()
int read_exit_code ()

Private Member Functions

void init_regular_expressions ()

Private Attributes

Regex sent_bytes_regex

Additional Inherited Members

Protected Attributes inherited from AsyncTask
DataOutputStream dos_log = null
Pid child_pid = 0
string script_file = ""
string working_dir = ""
Properties inherited from AsyncTask
string status_line [get, set]
double elapsed [get]
string stat_time_elapsed [get]
string??? stat_time_remaining [get]

Detailed Description

Definition at line 31 of file RsyncSpaceCheckTask.vala.

Constructor & Destructor Documentation

◆ RsyncSpaceCheckTask()

RsyncSpaceCheckTask.RsyncSpaceCheckTask ( )
inline

Member Function Documentation

◆ build_script()

override string RsyncSpaceCheckTask.build_script ( )
inlineprotected

Definition at line 78 of file RsyncSpaceCheckTask.vala.

78 {
79 var cmd = "export LC_ALL=C.UTF-8\n";
80
81 cmd += "rsync -aii";
82
83 cmd += " --recursive";
84
85 if (verbose){
86 cmd += " --verbose";
87 }
88 else{
89 cmd += " --quiet";
90 }
91
92 if (delete_extra){
93 cmd += " --delete";
94 }
95
96 if (delete_after){
97 cmd += " --delete-after";
98 }
99
100 cmd += " --force"; // allow deletion of non-empty directories
101
102 cmd += " --stats";
103
104 cmd += " --sparse";
105
106 if (delete_excluded){
107 cmd += " --delete-excluded";
108 }
109
110 cmd += " --dry-run";
111
112 if (link_from_path.length > 0){
113 if (!link_from_path.has_suffix("/")){
114 link_from_path = "%s/".printf(link_from_path);
115 }
116
117 cmd += " --link-dest='%s'".printf(escape_single_quote(link_from_path));
118 }
119
120 if (exclude_from_file.length > 0){
121 cmd += " --exclude-from='%s'".printf(escape_single_quote(exclude_from_file));
122
124 cmd += " --delete-excluded";
125 }
126 }
127
129
131
132 cmd += " '%s/'".printf(escape_single_quote(source_path));
133
134 cmd += " '%s/'".printf(escape_single_quote(dest_path));
135
136 return cmd;
137 }
string escape_single_quote(string file_path)
string remove_trailing_slash(string path)

References delete_after, delete_excluded, delete_extra, dest_path, TeeJee.FileSystem.escape_single_quote(), exclude_from_file, link_from_path, TeeJee.FileSystem.remove_trailing_slash(), source_path, and verbose.

◆ init_regular_expressions()

void RsyncSpaceCheckTask.init_regular_expressions ( )
inlineprivate

Definition at line 58 of file RsyncSpaceCheckTask.vala.

58 {
59 if (sent_bytes_regex != null){
60 return; // already initialized
61 }
62
63 try {
64 sent_bytes_regex = new Regex("""sent ([0-9,]+)[ \t]+bytes[ \t]+received""");
65 }
66 catch (Error e) {
67 log_error (e.message);
68 }
69 }
void log_error(string message, bool highlight=false, bool is_warning=false)

References Error, TeeJee.Logging.log_error(), and sent_bytes_regex.

Referenced by RsyncSpaceCheckTask().

◆ parse_stderr_line()

override void RsyncSpaceCheckTask.parse_stderr_line ( string err_line)
inline

◆ parse_stdout_line()

override void RsyncSpaceCheckTask.parse_stdout_line ( string out_line)
inline

◆ prepare()

override void RsyncSpaceCheckTask.prepare ( )
inlinevirtual

Reimplemented from AsyncTask.

Definition at line 71 of file RsyncSpaceCheckTask.vala.

71 {
72 base.prepare();
73
74 total_size = 0;
76 }

References status_line_count, and total_size.

◆ update_progress_parse_console_output()

bool RsyncSpaceCheckTask.update_progress_parse_console_output ( string line)
inline

Definition at line 149 of file RsyncSpaceCheckTask.vala.

149 {
150 if ((line == null) || (line.length == 0)) {
151 return true;
152 }
153
155
156 if (prg_count_total > 0){
159 }
160
161 MatchInfo match;
162
163 if (sent_bytes_regex.match(line, 0, out match)) {
164 total_size = int64.parse(match.fetch(1).replace(",",""));
165 }
166 else{
167 //log_debug("not-matched: %s".printf(line));
168 }
169
170 return true;
171 }
int64 prg_count
int64 prg_count_total
double progress

References AsyncTask.prg_count, AsyncTask.prg_count_total, AsyncTask.progress, sent_bytes_regex, status_line_count, and total_size.

Referenced by parse_stderr_line(), and parse_stdout_line().

Member Data Documentation

◆ delete_after

bool RsyncSpaceCheckTask.delete_after = false

Definition at line 35 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ delete_excluded

bool RsyncSpaceCheckTask.delete_excluded = false

Definition at line 36 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ delete_extra

bool RsyncSpaceCheckTask.delete_extra = true

Definition at line 34 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ dest_path

string RsyncSpaceCheckTask.dest_path = ""

Definition at line 42 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ dry_run

bool RsyncSpaceCheckTask.dry_run = false

Definition at line 45 of file RsyncSpaceCheckTask.vala.

◆ exclude_from_file

string RsyncSpaceCheckTask.exclude_from_file = ""

Definition at line 39 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ io_nice

bool RsyncSpaceCheckTask.io_nice = true

Definition at line 44 of file RsyncSpaceCheckTask.vala.

◆ link_from_path

string RsyncSpaceCheckTask.link_from_path = ""

Definition at line 40 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ relative

bool RsyncSpaceCheckTask.relative = false

Definition at line 37 of file RsyncSpaceCheckTask.vala.

◆ sent_bytes_regex

Regex RsyncSpaceCheckTask.sent_bytes_regex
private

◆ source_path

string RsyncSpaceCheckTask.source_path = ""

Definition at line 41 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().

◆ status_line_count

int64 RsyncSpaceCheckTask.status_line_count = 0

Definition at line 51 of file RsyncSpaceCheckTask.vala.

Referenced by prepare(), and update_progress_parse_console_output().

◆ total_size

int64 RsyncSpaceCheckTask.total_size = 0

◆ verbose

bool RsyncSpaceCheckTask.verbose = true

Definition at line 43 of file RsyncSpaceCheckTask.vala.

Referenced by build_script().


The documentation for this class was generated from the following file: