File tree Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Expand file tree Collapse file tree 1 file changed +9
-7
lines changed Original file line number Diff line number Diff line change 21
21
# Visit https://github.com/aboutcode-org/scancode.io for support and download.
22
22
23
23
import gzip
24
- import os
25
24
from datetime import datetime
25
+ from shutil import rmtree
26
26
27
27
import debian_inspector
28
28
from aboutcode import hashid
@@ -82,21 +82,23 @@ class DebianCollector:
82
82
83
83
def __init__ (self , index_location = None ):
84
84
if index_location :
85
+ self .index_download = None
85
86
self .index_location = index_location
86
87
else :
87
- self .index_location = self ._fetch_index ()
88
- self .index_location_given = bool ( index_location )
88
+ self .index_download = self ._fetch_index ()
89
+ self .index_location = self . index_download . path
89
90
90
91
def __del__ (self ):
91
- if self .index_location and not self . index_location_given :
92
- os . remove (self .index_location )
92
+ if self .index_download :
93
+ rmtree (self .index_download . directory )
93
94
94
95
def _fetch_index (self , uri = DEBIAN_LSLR_URL ):
95
96
"""
96
- Return a temporary location where the debian index was saved.
97
+ Fetch the Debian index at `uri` and return a Download with information
98
+ about where it was saved.
97
99
"""
98
100
index = fetch_http (uri )
99
- return index . path
101
+ return index
100
102
101
103
def get_packages (self , previous_index_last_modified_date = None , logger = None ):
102
104
"""Yield Package objects from debian index"""
You can’t perform that action at this time.
0 commit comments