[patch] check for tempdir

61 views
Skip to first unread message

Christian Brabandt

unread,
Dec 27, 2010, 4:07:57 PM12/27/10
to vim...@googlegroups.com
Hi Bram,
this patch checks, that the generated tmpdir does exist and not error
out. For example when a cron job deletes the v* temporary directory
(because it is too old). You can check this, if you manually delete the
/tmp/v* directory for a running vim session and afterwards run something
like :r !echo "foobar" or :echo system("echo foo")

With this patch, a new directory will be created, in case the old one
does not exist anymore and no error message will be displayed.

chrisbra@r500vm ~/code/vim/src (hg)-[default]- % hg qdiff
diff --git a/src/fileio.c b/src/fileio.c
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7353,7 +7353,7 @@
* It's also a bit faster, because we only need to check for an existing
* file when creating the directory and not for each temp file.
*/
- if (vim_tempdir == NULL)
+ if (vim_tempdir == NULL || !mch_isdir(vim_tempdir))
{
/*
* Try the entries in TEMPDIRNAMES to create the temp directory.


regards,
Christian

Bram Moolenaar

unread,
Dec 28, 2010, 1:47:25 PM12/28/10
to Christian Brabandt, vim...@googlegroups.com

Christian Brabandt wrote:

If the temp directory gets deleted that means any temp files are also
gone. That's already a problem, e.g., when running a ":make" that takes
a while. Creating the directory anew just lessens the problem.

There must be no cron jobs that delete temp files, that is a
configuration error. On FreeBSD the temp files are not even deleted on
reboot.

The check if the directory exists takes a bit of extra time.
If we really want to re-create the directory, it's better done when
something fails, to avoid this extra overhead that is unecessary in
99.99% of the cases.

--
hundred-and-one symptoms of being an internet addict:
48. You get a tatoo that says "This body best viewed with Netscape 3.1 or
higher."

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Reply all
Reply to author
Forward
0 new messages