save-cli icon indicating copy to clipboard operation
save-cli copied to clipboard

Remove tmp directories, created by plugins after their execution

Open kgevorkyan opened this issue 4 years ago • 3 comments

It seems, that we remove tmp directories only before plugin execution by clean() method. It's a good point, because if SAVE crashed on something during the previous execution, we anyway will remove old trash.

However, we hold all temp files after SAVE's work, it's seems to be not a good style, and probably we should remove tmp files before and after execution

kgevorkyan avatar Jun 29 '21 11:06 kgevorkyan

Under this task it also should be refactored cleanupTempDir it's abstract method in Plugin, which have the same logic in Warn and Fix, instead of name of directories. This name could be a property of corresponding plugins, and logic could be moved in to common logic

kgevorkyan avatar Jun 29 '21 11:06 kgevorkyan

We also should reconsider the way temporary directories are named. Now we usually use Plugin's ::class.simpleName, but this causes two parallel executions to clash. Now we are facing it only as flaking tests (e.g. I just saw on CI java.io.FileNotFoundException: /var/folders/24/8k48jl6d249_n_qfxwsl6xvm0000gn/T/FixPlugin/fix_and_warn/smoke/src/main/kotlin/org/cqfn/save/chapter1/Bug1Test.kt (No such file or directory), while native test is executed correctly. I believe this is caused by clash of directory names, because similar issues have been fixed, when we started using random directory names for our tests.

We should probably create a root tmp dir (like "$FileSystem.SYSTEM_TEMPORARY_DIRECTORY/save-tool") and delete it only after execution. And we can encapsulate all this logic in some sort of common tmp directory provider, which can also track a list of created directories.

petertrr avatar Oct 14 '21 11:10 petertrr

See also https://github.com/diktat-static-analysis/save/pull/310#discussion_r749432400

petertrr avatar Nov 17 '21 08:11 petertrr