def retrieve_file(url):
page_init()
db = get_db()
cur = db.cursor()
cur.execute("SELECT savefileLocation,name,uniqueIDForThisGame,download_enabled,download_url,id FROM playerinfo WHERE url="+app.sqlesc,(url,))
result = cur.fetchone()
if result[3] == True:
if result[4] == None:
filename = generateSavegame.createZip(url,result[1],result[2],'static/saves',result[0])
cur.execute('UPDATE playerinfo SET download_url='+app.sqlesc+' WHERE id='+app.sqlesc,(filename,result[5]))
db.commit()
return redirect(filename)
else:
return redirect(result[4])
elif 'admin' in session:
if result != None:
with open(legacy_location(result[0]),'rb') as f:
response = make_response(f.read())
response.headers["Content-Disposition"] = "attachment; filename="+str(result[1])+'_'+str(result[2])
return response
else:
g.error = _("URL does not exist")
else:
g.error = _("You are unable to download this farm data at this time.")
return render_template('error.html',**page_args())
评论列表
文章目录