fix duplicate + fix issue #200

This commit is contained in:
Terrtia 2018-05-11 13:25:45 +02:00
parent 559a98b537
commit d7ba5533be
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
2 changed files with 7 additions and 3 deletions

View file

@ -54,7 +54,7 @@ if __name__ == "__main__":
dico_redis[str(year)+str(month).zfill(2)] = redis.StrictRedis(
host=p.config.get("ARDB_DB", "host"),
port=p.config.get("ARDB_DB", "port"),
db='year' + 'month',
db=str(year) + str(month),
decode_responses=True)
# FUNCTIONS #

View file

@ -121,7 +121,7 @@ class Paste(object):
except:
paste = ''
return paste
return str(paste)
def get_p_content_as_file(self):
message = StringIO(self.get_p_content())
@ -332,7 +332,11 @@ class Paste(object):
json_duplicate = self.store.hget(path, attr_name)
#json save on redis
if json_duplicate is not None:
list_duplicate = json.loads(json_duplicate)
list_duplicate = (json.loads(json_duplicate))
# avoid duplicate
list_duplicate = set(tuple(row) for row in list_duplicate)
list_duplicate = [list(item) for item in set(tuple(row) for row in list_duplicate)]
# add new duplicate
list_duplicate.append([hash_type, self.p_path, percent, date])
self.store.hset(path, attr_name, json.dumps(list_duplicate))