summaryrefslogtreecommitdiff
path: root/lib/syntax_suggest/api.rb
diff options
context:
space:
mode:
authorschneems <[email protected]>2023-03-07 17:49:11 -0600
committerHiroshi SHIBATA <[email protected]>2023-04-06 15:45:27 +0900
commit33cfd262fcfe65737b6d4cde416a24cd81406885 (patch)
treedd12cb93f63366dbe4fe590f1503fac9bb1a2d76 /lib/syntax_suggest/api.rb
parent588dd44d418d56dce3f2a388c4021d11f9aa4324 (diff)
[ruby/syntax_suggest] Handle alias already exists when debugging
When `tmp/alias` already exists, I'm now getting phantom folders in the directory pointing at older aliases which is distracting/confusing. By checking and removing that alias before symlinking we can prevent this strange behavior (possibly caused by newer Mac OS?).
Diffstat (limited to 'lib/syntax_suggest/api.rb')
-rw-r--r--lib/syntax_suggest/api.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/syntax_suggest/api.rb b/lib/syntax_suggest/api.rb
index 5b725e13d7..ad8f641dbf 100644
--- a/lib/syntax_suggest/api.rb
+++ b/lib/syntax_suggest/api.rb
@@ -91,7 +91,9 @@ module SyntaxSuggest
dir = Pathname(dir)
dir.join(time).tap { |path|
path.mkpath
- FileUtils.ln_sf(time, dir.join("last"))
+ alias_dir = dir.join("last")
+ FileUtils.rm_rf(alias_dir) if alias_dir.exist?
+ FileUtils.ln_sf(time, alias_dir)
}
end