Merge "Don't add duplicate entries to metadata.txt"

This commit is contained in:
Jenkins 2016-04-20 09:07:06 +00:00 committed by Gerrit Code Review
commit c425c56765
1 changed files with 4 additions and 2 deletions

View File

@ -30,8 +30,10 @@ def saveform(form, storagedir):
fp.close()
shutil.move(fp.name, filename)
else:
fp = open(os.path.join(storagedir, "metadata.txt"), "a")
fp.write("%s=%s\n" % (entry.name, entry.value))
line = "%s=%s\n" % (entry.name, entry.value)
fp = open(os.path.join(storagedir, "metadata.txt"), "a+")
if line not in fp.read():
fp.write(line)
fp.close()
def run():