Skip to content

Commit af71cb0

Browse files
authored
v.util: use tmp instead of cache dir for temporary diff files (#21075)
1 parent cb9a875 commit af71cb0

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

vlib/v/util/diff/diff.v

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,16 @@ pub fn color_compare_files(diff_cmd string, file1 string, file2 string) string {
8484
}
8585

8686
pub fn color_compare_strings(diff_cmd string, unique_prefix string, expected string, found string) string {
87-
cdir := os.join_path_single(os.cache_dir(), unique_prefix)
88-
os.mkdir(cdir) or {}
87+
tmp_dir := os.join_path_single(os.vtmp_dir(), unique_prefix)
88+
os.mkdir(tmp_dir) or {}
89+
defer {
90+
os.rmdir_all(tmp_dir) or {}
91+
}
8992
ctime := time.sys_mono_now()
90-
e_file := os.join_path_single(cdir, '${ctime}.expected.txt')
91-
f_file := os.join_path_single(cdir, '${ctime}.found.txt')
93+
e_file := os.join_path_single(tmp_dir, '${ctime}.expected.txt')
94+
f_file := os.join_path_single(tmp_dir, '${ctime}.found.txt')
9295
os.write_file(e_file, expected) or { panic(err) }
9396
os.write_file(f_file, found) or { panic(err) }
9497
res := color_compare_files(diff_cmd, e_file, f_file)
95-
os.rmdir_all(cdir) or {}
9698
return res
9799
}

0 commit comments

Comments
 (0)