Skip to content

Commit

Permalink
remove another use of rm
Browse files Browse the repository at this point in the history
  • Loading branch information
ygerlach committed Sep 19, 2024
1 parent 31fe959 commit 05c2c1c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
24 changes: 5 additions & 19 deletions src/Core/SnapshotRepo.vala
Original file line number Diff line number Diff line change
Expand Up @@ -925,32 +925,18 @@ public class SnapshotRepo : GLib.Object{
}

public void cleanup_symlink_dir(string tag){
string cmd = "";
string std_out;
string std_err;
int ret_val;

try{
string path = "%s-%s".printf(snapshots_path, tag);
var f = File.new_for_path(path);
if (f.query_exists()){
cmd = "rm -rf \"%s\"".printf(path + "/");

if (LOG_COMMANDS) { log_debug(cmd); }

Process.spawn_command_line_sync(cmd, out std_out, out std_err, out ret_val);
if (ret_val != 0){
log_error (std_err);
log_error(_("Failed to delete symlinks") + ": 'snapshots-%s'".printf(tag));
return;
}
if(!TeeJee.FileSystem.dir_delete_recursive(path)) {
log_error(_("Failed to delete symlinks") + ": '%s'".printf(path));
}

File f = File.new_for_path(path);
f.make_directory_with_parents();
}
catch (Error e) {
log_error (e.message);
}
log_error (e.message);
}
}

}
Expand Down
8 changes: 4 additions & 4 deletions src/Utility/TeeJee.FileSystem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ namespace TeeJee.FileSystem{
return true;
}

public bool dir_delete(string dir_path, bool show_message = false) {
public static bool dir_delete(string dir_path, bool show_message = false) {

/* Recursively deletes directory along with contents */

bool status = dir_delete_recursive(dir_path);

if (show_message){
Expand All @@ -360,7 +360,7 @@ namespace TeeJee.FileSystem{
log_error(_("Failed to delete directory") + ": %s".printf(dir_path));
}
}

return status;
}

Expand Down

0 comments on commit 05c2c1c

Please sign in to comment.