The database connection is saved in a pool, and the pool serves out a connection to any object that needs them.
At the moment, we use SQLX, with SQLite, however I'd really like to support Postgres and the rest soon, SQLite is slow, buggy and annoying. Issue: #7
Database Tables
files
-
file as
text
: Contains the filename (with filetype!) -
mimetype as
text
: Contains the guessed mimetype. We use this for restricting filetypes and cool stats. -
expiry as
int
: Contains unix time of when the file will be deleted - AS COMPUTED BY ENGINE MODE. (this is kept as is, never changed after initial upload) -
expiry_override as
int
: Optionally contains the unixtime of when the file will actually be deleted, if it's set, this is used for overriding the expiry. -
views as
int
: Counter for file views. -
isDeleted as
int
: Marks if the file has been deleted from disk. -
owner as
text
: The API Key that uploaded the file. -
uploaded as
int
: The unixtime the file was uploaded. -
last_acces as
int
: The unixtime of the last file view. -
filesize as
int
: size of the file, in kb or something idk -
ip as
text
: IP Address of the uploader, for legal and statistics purposes! -
domain as
text
: Domain the file was originally uploaded to.
qrcode_stats
-
scanid as
autoincrement int
: Primary Key. -
time as
int
: When the qr code was scanned. - ip as text: The IP who scanned the code.
-
useragent as
text
: The useragent of who scanned the code. -
version as
int
: Simple version number, so we can have unique codes.
Keys
-
uuid as
text
: The generated key. -
key_level as
int
: The Permission level (key level) of the key. -
parent_key as
text
: The uuid of the parent who generated this key. -
creation_time as
int
: The unixtime when this key was created. -
comment as
text
: The comment/note of the key.
mimetype_stats
TODO: I've actually gotta implement this, but it would be nice.
This would be a lazily updated table, so it updates the view whenever it can, allowing for faster reading of metrics.
-
mimetype as
text
: The mimetype group. Primary Key. -
files_alive as
text
: The number of living files uploaded for a given mimetype. -
files_dead as
text
: The number of deleted files uploaded for a given mimetype. -
views as
int
: The number of views for a given mimetype. -
size_alive as
int
: The total size of all alive files of the given mimetype. -
size_dead as
int
: The total size of all alive files of the given mimetype.
file_block_stats
TODO: I've actually gotta implement this, but it would be nice.
This would be a lazily updated table, so it updates the view whenever it can, allowing for faster reading of metrics.
-
mimetype as
text
: The mimetype group. Primary Key. -
files_blocked as
int
: How many times a given mimetype was blocked from uploading -
files_bypassed as
int
: How many times a normally blocked mimetype bypassed the block. (Super/Master Keys)
server_stats
TODO: I've actually gotta implement this, but it would be nice.
-
error_type as
text
: The type of error. -
count as
int
: How many times has this error occurred.