Problem with idea system directory and windows search indexer

Good day,

I've got the following problem:

Our plugin uses a library which creates temporary files. It works fine outside of Idea. However, when the code is running in Idea, it sometimes fails with exceptions ("access denied", or ".. operation cannot be performed on a file with a user-mapped section open") reported for those temporary files. It does not happen every time, but it's still possible to reproduce it on big data.

I found out that the temporary files are opened (and locked) by the Windows Search indexer. (I can turn it off on my machine, and after that everything works fine. However, it's not a solution for the plugin itself.)

Now, the tricky part. By default, Windows Search indexes content of all files under C:\Users\username, except for AppData (and, in particular, except for AppData\Local\Temp, which is the default temp directory). (Open Start > Indexing Options to see details). However, Idea uses the system directory C:\Users\username\.IdeaIC12\system; and changes the temp directory to C:\Users\username\.IdeaIC12\system\tmp. So, the system temp dir is NOT indexed, but the Idea temp dir IS indexed. After that, new files created using File.createNewFile /Directory are locked by indexer at random time.

There are similar problems reported by other people for files in idea system directory (search for "user-mapped section open" here on forums, or in bug tracker). I could not find an acceptable solution, though - all the answers are "turn off the indexer / antivirus".

Now, the questions:

1) from plugin dev perspectivve: did anyone find a solution for such problem?

- is it possible to somehow obtain the real system temp directory from idea (I can pass that temp directory to the library).
- anyone managed to successfully set NOT_CONTENT_INDEXED flag to files/directories?
- etc.

2) the Idea itself:

- is it possible to exclude the whole idea system directory from the indexing just after idea installation?
- or, what was the point of changing the temp directory? Isn't it better to use system temp directory?



Temp dir location is changed for internal needs. You can obtain standard location via System.getProperty("") and pass it to your library.


Thanks for the workaround, it worked for me.

But wait a minute, File.createTempFile() uses exactly the same property to get the system temp dir. How do you manage to keep the system property unchanged, and override the createTempFile behaviour?

(I want to make sure this workaround is good for all platforms / JVMs / Idea versions / future Idea versions / etc.)



Nevermind, I found the StartupUtil sources; guessing you had to play with temp dir to avoid problems with jna. I feel your pain.

Now, is an official workaround for plugin devs; or it's better to read "" manually, as suggested above?



Please sign in to leave a comment.