right now, to see if a paste exists, we check if the file exists
|
if not paste_path.exists(): |
lets instead rely on sqlite as the source of truth for a paste existing or not. we can look up the paste via id
we can do a function like
def paste_exists(sqlite_file: str, paste_id: int) -> bool:
db = sqlite3.connect(sqlite_file)
cursor = db.cursor()
try:
cursor.execute("SELECT id FROM pastes WHERE id = ?", (paste_id,))
return cursor.fetchone() is not None
except Exception:
logger.exception("Getting paste had an error")
return False
finally:
cursor.close()
db.close()
verifying if this works
see the create/view a paste section in https://github.com/SCE-Development/cleezy#to-create-a-paste
we can try the "view paste" curl command on a not real id, and see if 404 is returned
right now, to see if a paste exists, we check if the file exists
cleezy/server.py
Line 215 in 75dcf1a
lets instead rely on sqlite as the source of truth for a paste existing or not. we can look up the paste via id
we can do a function like
verifying if this works
see the create/view a paste section in https://github.com/SCE-Development/cleezy#to-create-a-paste
we can try the "view paste" curl command on a not real id, and see if 404 is returned