@@ -179,24 +179,34 @@ def remove_cache_items(self, options, args):
179
179
180
180
files = self ._find_wheels (options , args [0 ])
181
181
182
- # Only fetch http files if no specific pattern given
183
- if args [0 ] == '*' :
184
- files += self ._find_http_files (options )
185
-
186
182
if not files :
187
183
raise CommandError ('No matching packages' )
188
184
189
185
for filename in files :
190
186
os .unlink (filename )
191
187
logger .debug ('Removed %s' , filename )
188
+
189
+ dirs = filesystem .list_empty_subdirs (self ._cache_dir (options , 'http' )) + \
190
+ filesystem .list_empty_subdirs (self ._cache_dir (options , 'wheels' ))
191
+ for dirname in dirs :
192
+ os .rmdir (dirname )
193
+
192
194
logger .info ('Files removed: %s' , len (files ))
195
+ logger .info ('Empty directories removed: %s' , len (dirs ))
193
196
194
197
def purge_cache (self , options , args ):
195
198
# type: (Values, List[Any]) -> None
196
199
if args :
197
200
raise CommandError ('Too many arguments' )
198
201
199
- return self .remove_cache_items (options , ['*' ])
202
+ # Remove everything in the "http" and "wheels" cache directories.
203
+ filesystem .remove_subdirs (self ._cache_dir (options , 'http' ))
204
+ filesystem .remove_subdirs (self ._cache_dir (options , 'wheels' ))
205
+
206
+ # selfcheck.json is no longer used by pip.
207
+ selfcheck_json = self ._cache_dir (options , 'selfcheck.json' )
208
+ if os .path .isfile (selfcheck_json ):
209
+ os .remove (selfcheck_json )
200
210
201
211
def _cache_dir (self , options , subdir ):
202
212
# type: (Values, str) -> str
0 commit comments