Skip to content

Commit

Permalink
Bug fix for cache management of latesthashes.txt list
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonzo committed Oct 25, 2019
1 parent 8f359f8 commit f7d6b59
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Changelog
=========

1.8.2 (2019-10-25)
------------------

* Bug fix for cache management of latesthashes.txt list

1.8 (2019-10-22)
----------------

Expand Down
12 changes: 7 additions & 5 deletions apiosintDS/modules/listutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def getCache(self): #Mmhhh, not a good method at all, but works. Added to TODO l
for entity in self.entities["centities"]:
getHash = (True if entity == "hash" else False)
cached[entity] = {}
cached[entity]["file"] = "latest"+entity+"s.txt"
cached[entity]["file"] = "latest"+entity+"es.txt" if entity == "hash" else "latest"+entity+"s.txt"
if (self.entities["centities"][entity] == 0) and (entity in ["ip", "domain"]):
pass
else:
Expand All @@ -107,20 +107,22 @@ def getCache(self): #Mmhhh, not a good method at all, but works. Added to TODO l
if os.path.exists(cachedfile):
if self.clearcache:
dwlist = self.downloadLists(entity, getHash)
cached[entity]["date"] = self.getListDate(dwlist["text"])
cached[entity]["items"] = self.getListItems(dwlist["text"])
cached[entity]["date"] = self.getListDate(dwlist["text"], getHash)
cached[entity]["items"] = self.getListItems(dwlist["text"], getHash)
cached[entity]["url"] = dwlist["url"]
else:
if entity == "hash":
dwlist = json.loads(cacheddownloadListsfile)
cacheHandler = open(cachedfile, 'r')
content = cacheHandler.read()
cacheHandler.close()
dwlist = content
else:
dwlist = [line.rstrip('\n') for line in open(cachedfile)]

listdate = self.getListDate(dwlist, getHash)
listitems = self.getListItems(dwlist, getHash)

diffdate = ((self.checkdate-listdate).total_seconds())/3600

if ((diffdate) < 4) and (len(listitems) > 0):
cached[entity]["date"] = listdate
cached[entity]["items"] = listitems
Expand Down

0 comments on commit f7d6b59

Please sign in to comment.