")
def download(filename):
@@ -144,13 +145,13 @@ def createNewTorrent(reuqest):
newTFile.metadata.writeToDb(connection.cursor())
connection.commit()
connection.close()
- return ["Success"]
except sqlite3.IntegrityError as e:
print(e)
- return ["Torrent {} does already exist".format(info_hash, info_hash[:-20])]
+ newTFile.errors = ["Torrent {} already exists".format(info_hash, info_hash[:-20])]
except Exception as e:
- print(e)
- return ["Unknown error in creation"]
+ newTFile.errors = ["Unknown error in creation"]
+
+ return newTFile
class Metadata():
def __init__(self, fileid):
@@ -175,6 +176,7 @@ class Metadata():
c.execute("INSERT INTO metadata(fileid, created_by, creation_date, announce_url, source, torrentsize, name, private) VALUES(:fileid, :created_by, :creation_date, :announce_url, :source, :torrentsize, :name, :private)", { 'fileid' : self.fileid, 'created_by' : b64created_by, 'creation_date' : self.creation_date, 'announce_url' : b64announce_url, 'source' : b64source , 'torrentsize' : self.torrentsize, 'name' : b64name, 'private' : self.private})
class TorrentFile():
+ errors = []
fileid = None
name = None
category = None
diff --git a/templates/create.html b/templates/create.html
index 28f708e..c9affb8 100644
--- a/templates/create.html
+++ b/templates/create.html
@@ -17,6 +17,14 @@ vim: ts=2 noexpandtab
{% endfor %}
{% endif %}
+ {% if messages %}
+ {% for message in messages %}
+
+
+ {{ message|safe }}
+
+ {% endfor %}
+ {% endif %}