File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2438,7 +2438,9 @@ def table_name(
24382438
24392439 def clear_caches (self ) -> None :
24402440 for path in self .configs :
2441- rmtree (path / c .CACHE )
2441+ cache_path = path / c .CACHE
2442+ if cache_path .exists ():
2443+ rmtree (cache_path )
24422444 if isinstance (self .state_sync , CachingStateSync ):
24432445 self .state_sync .clear_cache ()
24442446
Original file line number Diff line number Diff line change @@ -640,6 +640,11 @@ def test_clear_caches(tmp_path: pathlib.Path):
640640 assert not cache_dir .exists ()
641641 assert models_dir .exists ()
642642
643+ # Test clearing caches when cache directory doesn't exist
644+ # This should not raise an exception
645+ context .clear_caches ()
646+ assert not cache_dir .exists ()
647+
643648
644649def test_ignore_files (mocker : MockerFixture , tmp_path : pathlib .Path ):
645650 mocker .patch .object (
You can’t perform that action at this time.
0 commit comments