Skip to content
This repository was archived by the owner on Oct 16, 2022. It is now read-only.

Commit 335b3d5

Browse files
committed
Change TEMP_DIR permissions and path; Cleanup on exit;
1 parent 4447b0a commit 335b3d5

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

Diff for: src/Core/Main.vala

+2
Original file line numberDiff line numberDiff line change
@@ -4244,6 +4244,8 @@ public class Main : GLib.Object{
42444244
clean_logs();
42454245

42464246
app_lock.remove();
4247+
4248+
dir_delete(TEMP_DIR);
42474249

42484250
exit(exit_code);
42494251

Diff for: src/Utility/TeeJee.FileSystem.vala

+7
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,11 @@ namespace TeeJee.FileSystem{
344344

345345
try{
346346
var dir = File.parse_name (dir_path);
347+
347348
if (dir.query_exists () == false) {
349+
348350
bool ok = dir.make_directory_with_parents (null);
351+
349352
if (show_message){
350353
if (ok){
351354
log_msg(_("Created directory") + ": %s".printf(dir_path));
@@ -355,6 +358,7 @@ namespace TeeJee.FileSystem{
355358
}
356359
}
357360
}
361+
358362
return true;
359363
}
360364
catch (Error e) {
@@ -373,9 +377,12 @@ namespace TeeJee.FileSystem{
373377
}
374378

375379
string cmd = "rm -rf '%s'".printf(escape_single_quote(dir_path));
380+
376381
log_debug(cmd);
382+
377383
string std_out, std_err;
378384
int status = exec_sync(cmd, out std_out, out std_err);
385+
379386
if (show_message){
380387
if (status == 0){
381388
log_msg(_("Deleted directory") + ": %s".printf(dir_path));

Diff for: src/Utility/TeeJee.Process.vala

+8-5
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,17 @@ namespace TeeJee.ProcessHelper{
3636
public static void init_tmp(string subdir_name){
3737
string std_out, std_err;
3838

39-
TEMP_DIR = Environment.get_tmp_dir() + "/" + subdir_name + "/" + random_string();
39+
TEMP_DIR = Environment.get_tmp_dir() + "/" + random_string();
4040
dir_create(TEMP_DIR);
41-
41+
chmod(TEMP_DIR, "0750");
42+
4243
exec_script_sync("echo 'ok'",out std_out,out std_err, true);
43-
if ((std_out == null)||(std_out.strip() != "ok")){
44-
TEMP_DIR = Environment.get_home_dir() + "/.temp/" + subdir_name + "/" + random_string();
45-
exec_sync("rm -rf '%s'".printf(TEMP_DIR), null, null);
44+
45+
if ((std_out == null) || (std_out.strip() != "ok")){
46+
47+
TEMP_DIR = Environment.get_home_dir() + "/.temp/" + random_string();
4648
dir_create(TEMP_DIR);
49+
chmod(TEMP_DIR, "0750");
4750
}
4851

4952
//log_debug("TEMP_DIR=" + TEMP_DIR);

0 commit comments

Comments
 (0)