Skip to content

instead of checking if file exists, use sqlite to see if paste exists #76

Description

@evanugarte

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions