Skip to content

Commit 9449ee2

Browse files
committed
Fix logic in destructor #660
Signed-off-by: Jono Yang <[email protected]>
1 parent 88956bf commit 9449ee2

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

minecode_pipelines/pipes/maven.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,15 @@ class MavenNexusCollector:
587587

588588
def __init__(self, index_location=None, index_properties_location=None):
589589
self._set_index_properties(index_properties_location=index_properties_location)
590-
self.index_location = index_location
590+
if index_location:
591+
self.index_location = index_location
592+
else:
593+
self.index_location = self._fetch_index()
591594
self.index_location_given = bool(index_location)
592595
self.index_increment_locations = []
593596

594597
def __del__(self):
595-
if self.index_location and self.index_location_given:
598+
if self.index_location and not self.index_location_given:
596599
os.remove(self.index_location)
597600
if self.index_increment_locations:
598601
for loc in self.index_increment_locations:
@@ -603,7 +606,6 @@ def _fetch_index(self, uri=MAVEN_INDEX_URL):
603606
Return a temporary location where the maven index was saved.
604607
"""
605608
index = fetch_http(uri)
606-
self.index_location = index.path
607609
return index.path
608610

609611
def _fetch_index_properties(self, uri=MAVEN_INDEX_PROPERTIES_URL):
@@ -712,8 +714,6 @@ def get_packages(self, last_incremental=None):
712714
if last_incremental:
713715
packages = chain(self._get_packages_from_index_increments(last_incremental=last_incremental))
714716
else:
715-
if not self.index_location:
716-
self._fetch_index()
717717
packages = self._get_packages(content=self.index_location)
718718
return packages
719719

0 commit comments

Comments
 (0)