bug fixes

This commit is contained in:
Jack Eilles 2024-01-08 11:36:53 +00:00
parent f037e8b62c
commit a7c5b3a9bc
3 changed files with 24 additions and 7 deletions

View file

@ -166,9 +166,7 @@ def getInfo(id):
@login_required
def delete(id):
if Config.files.find_one({"id": id}) is not None:
if Config.files.find_one({"id": id}) is None:
return Errors.file404
else:
data = Config.files.find_one({"id": id})
if data["userid"] == current_user.userid:
@ -184,6 +182,24 @@ def delete(id):
else:
return "You are not the owner of this file."
elif Config.url.find_one({"id": id}) is not None:
data = Config.url.find_one({"id": id})
if data["userid"] == current_user.userid:
Config.files.delete_one({"id": id})
return "URL deleted."
elif data["userid"] == request.form.get("userid") and bcrypt.check_password_hash(Config.user.find_one({"userid": data["userid"]})["idpass"], request.form.get("idpass")):
Config.files.delete_one({"id": id})
return "URL deleted."
else:
return "You are not the owner of this link."
else:
return "This ID does not exist."
@app.route('/teapot')
def teapot():
return 'I\'m a teapot. 418.', 418

View file

@ -17,6 +17,7 @@
<table>
<tr>
<th>ID</th>
<th>Filename</th>
<th>Size</th>
<th>Retention</th>

View file

@ -40,9 +40,9 @@ def main():
os.remove(os.path.join(Config.fileDir, file["filename"]))
# Delete all expired URL's
for url in expiredURLs:
print(f"Deleting URL {url['id']}")
Config.url.delete_one({"id": url["id"]})
for urls in expiredURLs:
print(f"Deleting URL {urls['id']}")
Config.url.delete_one({"id": urls["id"]})
print("Cleanup complete.")
time.sleep(60)