Skip to content

Conversation

erw7
Copy link
Contributor

@erw7 erw7 commented Oct 25, 2019

Since vim_tempdir cached on Windows may not exist, change it to check the existence. It is presumed to be removed by the antivirus software cleanup process.

Fixes #11250
Fixes #9833
Fixes #1432
Related: f50135a stdpath("run")

Since vim_tempdir cached on Windows may not exist, change it to check
the existence. It is presumed to be removed by the antivirus software
cleanup process.
@justinmk
Copy link
Member

Good idea, confirmed as follows:

mkdir foo
TMPDIR=./foo nvim
:echo tempname()
!rm -r foo
:echo tempname()

tempname() still uses the foo path even though it was deleted, so any plugin using tempname() will break. I wonder why this check wasn't done...

@marvim marvim added the WIP label Oct 25, 2019
@erw7 erw7 changed the title [WIP] Change to check the existence of vim_tempdir [RFC] Change to check the existence of vim_tempdir Oct 25, 2019
@marvim marvim added RFC and removed WIP labels Oct 25, 2019
@chrisbra
Copy link
Contributor

tempname() still uses the foo path even though it was deleted, so any plugin using tempname() will break. I wonder why this check wasn't done...

For performance reasons. I did suggest doing something like this years ago, but Bram did not want to check for the existence of the path everytime a temp path was created. Rather it was pointed out, that the temporary directory should not be removed (and the system is brocken).

@chrisbra
Copy link
Contributor

Some more information.

See here:
https://groups.google.com/d/msg/vim_use/qgRob9SWDv8/FAOFVVcDTv0J
(I use the provided command Mktempdir)

and here for my old patch:
https://groups.google.com/d/msg/vim_dev/cogp-Vye4oo/d_SVFXBbnnoJ

@justinmk
Copy link
Member

justinmk commented Oct 25, 2019

Thanks @chrisbra !

did not want to check for the existence of the path everytime a temp path was created

I would guess creating a file is far more expensive than os_isdir, so avoiding os_isdir gains relatively little.

I agree that a temp dir going missing is indicative of a broken system, so we should (also) show an error . Something like this:

  if (vim_tempdir == NULL || !os_isdir(vim_tempdir)) {
    if (vim_tempdir != NULL) {
      emsgf("EXX: tempdir went missing (antivirus or misconfigured cleanup job?)");
      XFREE_CLEAR(vim_tempdir);
    }
    vim_maketempdir();
  }

@chrisbra
Copy link
Contributor

If you are re-creating the temp directory, why bothering with an error message?

@justinmk
Copy link
Member

Because such a system is likely in a bad state and even after creating the directory, some plugins are likely broken.

@justinmk
Copy link
Member

This will close #1432

@justinmk justinmk removed the RFC label Jan 28, 2020
@erw7 erw7 changed the title [RFC] Change to check the existence of vim_tempdir Change to check the existence of vim_tempdir Jan 29, 2020
@janlazo
Copy link
Contributor

janlazo commented Nov 14, 2020

@erw7 Any issues with adding the error message?

@erw7
Copy link
Contributor Author

erw7 commented Nov 14, 2020

Any issues with adding the error message?

Yes, I think we should add an error message as well. I think the reason I didn't add the error message is because I didn't know how to assign EXX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs:response waiting for reply from the author platform:windows
Projects
None yet
5 participants