File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -139,9 +139,10 @@ def popitem(self):
139139 """重写 popitem 方法,在驱逐缓存项时清理 kubeconfig 文件"""
140140 key , path = super ().popitem ()
141141 # 删除 kubeconfig 文件
142- if (path and os .path .exists (path ) and
143- self .do_not_cleanup_file and
144- os .path .abspath (path ) != os .path .abspath (self .do_not_cleanup_file )):
142+ if path and os .path .exists (path ):
143+ if self .do_not_cleanup_file and os .path .samefile (path , self .do_not_cleanup_file ):
144+ logger .debug (f"Skipped removal of protected kubeconfig file: { path } " )
145+ return
145146 try :
146147 os .remove (path )
147148 logger .debug (f"Removed cached kubeconfig file: { path } " )
@@ -156,7 +157,7 @@ def cleanup(self):
156157 for key , path in list (self .items ()):
157158 if path and os .path .exists (path ):
158159 # 只有当do_not_cleanup_file存在且路径不同时才清理
159- if self .do_not_cleanup_file and os .path .abspath (path ) == os . path . abspath ( self .do_not_cleanup_file ):
160+ if self .do_not_cleanup_file and os .path .samefile (path , self .do_not_cleanup_file ):
160161 continue
161162 try :
162163 os .remove (path )
You can’t perform that action at this time.
0 commit comments