Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
dd11e73
refactor: use `sqlx` over surreal
onkoe Jan 15, 2025
fc39bc9
chore: remove database from tree lol
onkoe Jan 15, 2025
cd9b4dd
chore: file structure for `sqlx` migrations
onkoe Jan 15, 2025
76e91c5
feat(db): automatic migrations via `sqlx`
onkoe Jan 15, 2025
8a44cc5
feat(db): rename database file to `raves.sqlite`
onkoe Jan 15, 2025
3f02b41
fix(sqlx): use rt-tokio ft to avoid runtime panic
onkoe Jan 16, 2025
8dddccd
fix(db): make path not unique
onkoe Jan 16, 2025
7dea102
feat(db): add `InsertIntoTable` trait
onkoe Jan 16, 2025
910a742
feat(media): impl `InsertIntoTable` for `Media`
onkoe Jan 16, 2025
5d1a5ff
fix(media/load): reimpl`load_from_disk` with sqlx
onkoe Jan 16, 2025
cd63e4e
chore(media): remove commented out surreal queries
onkoe Jan 16, 2025
2d57bae
test(db): test for database handling of media
onkoe Jan 16, 2025
142e69a
fix(meta/kamadak): use correct exif tags for w/h
onkoe Jan 16, 2025
4b61695
refactor(meta/kamadak): better err handling
onkoe Jan 16, 2025
73de758
feat: use `tokio-unstable` cfg
onkoe Jan 17, 2025
da7226a
docs(lib.rs): talk about recommended ppl tags
onkoe Jan 17, 2025
255ef0f
feat(db): make crate users specify db location
onkoe Jan 17, 2025
5be70c9
refactor(watch): get config ourselves
onkoe Jan 17, 2025
465b307
fix(watch): various bugs from iterator.map lol
onkoe Jan 17, 2025
9b0b922
docs(README): add info about required calls
onkoe Jan 17, 2025
1f9666d
test(db): add integration test mod for database
onkoe Jan 17, 2025
537b461
feat(meta): add support for `avif` files!
onkoe Jan 17, 2025
b9e83ac
fix(test, common): actually call `init_config`
onkoe Jan 17, 2025
49d3537
test(watch): integration test for file watcher
onkoe Jan 17, 2025
b9b0209
fix(mediabuilder): keep static fields from db
onkoe Jan 17, 2025
a5cebfa
test(mediabuilder): ensure static data stays
onkoe Jan 17, 2025
13dae1f
refactor(models/meta): dump meta types into mod.rs
onkoe Jan 17, 2025
485a4d6
feat(media): add hash table + type
onkoe Jan 17, 2025
d5e9f7a
feat(hash): add `InsertIntoTable` trait impl
onkoe Jan 17, 2025
862de07
feat(error, hash): add HashError type
onkoe Jan 17, 2025
5007069
feat(hash): add constructor functions
onkoe Jan 17, 2025
f06ea42
feat(hash): `add_to_table` method for ezpz inserts
onkoe Jan 17, 2025
309f3f7
feat(media): method on Media to compute hash
onkoe Jan 17, 2025
f9c2d69
test(hash): try hashing beach media file :)
onkoe Jan 17, 2025
0789ace
feat(error): `RavesError::HashError` #from variant
onkoe Jan 17, 2025
79239b6
chore(test): track tokio-console ports
onkoe Jan 17, 2025
13c0e4f
fix(Media/Builder): use canonicalized paths
onkoe Jan 17, 2025
903264d
feat(media): use file hashes when updating metadat
onkoe Jan 17, 2025
9160131
test(hash): ensure hash matches hardcoded val
onkoe Jan 17, 2025
71e5823
refactor(metadata): move to `media::metadata`
onkoe Jan 17, 2025
8b4dfe2
chore: remove unused `lib.rs` template func
onkoe Jan 17, 2025
7538f36
refactor(watch): move to just one file
onkoe Jan 17, 2025
329b94b
fix(m/hash): sqlite conflict resolution for insert
onkoe Jan 17, 2025
599b6a8
refactor(media): unify all `media` constructors
onkoe Jan 17, 2025
d9bef60
refactor(MediaBuilder): make module suck less
onkoe Jan 18, 2025
f712857
ci(fix): install `yasm` and rm useless semver ck
onkoe Jan 18, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg", "tokio_unstable"]
15 changes: 4 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Install `nasm`
run: sudo apt-get install yasm -y

- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
Expand Down Expand Up @@ -72,14 +75,4 @@ jobs:
run: cargo nextest run

- name: Run doctests
run: cargo test --doc



test_semver:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2
run: cargo test --doc
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/target
raves_media_info.db/
raves_thumbnails.db/
**.db
**.sqlite
Cargo.lock
_BACKUP_BEFORE_MERGING_MEDIA_AND_RECORD/
build/

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 9 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ image = "0.25.2"
infer = "0.16.0"
mp4parse = "0.17.0"
matroska = "0.27.0"
camino = { version = "1.1.9", features = ["serde", "serde1"] }
sqlx = { version = "0.8.3", features = ["sqlite", "chrono", "json", "macros", "uuid", "runtime-tokio"] }
chrono = { version = "0.4.39", features = ["serde"] }
constcat = "0.5.1"
uuid = { version = "1.12.0", features = ["v4", "serde"] }
avif-parse = "1.3.2"
blake3 = { version = "1.5.5", features = ["mmap", "rayon"] }
# crc32fast = "1.4.2"

# sys dependencies
Expand All @@ -51,15 +58,10 @@ branch = "master"
# features = ["build", "static"]
features = ["build"]


[dependencies.surrealdb]
package = "surrealdb-nightly"
version = "2.0.20240903"
default-features = true
features = ["kv-surrealkv"]

[dev-dependencies]
async-ctrlc = "1.2.0"
clap = { version = "4.5.17", features = ["derive"] }
tracing-subscriber = "0.3.18"
dirs = "5.0.1"
anyhow = "1.0.95"
console-subscriber = "0.4.1"
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Under active development.
- If we go the route of having People (i.e. machine learning), we should be able to associate folks with their tags.
- If a person is named "Barrett", allow users to associate them with the "barrett" tag (or any other).
- for UI: warn on low overlap.
- [ ] Recommended people tags
- When they know someone is often involved with other tags, a user can add tags to show up by default.
- ex: Dad has "family", "home", "overweight", etc.
- [ ] Search
- You should be able to search the database for virtually anything.
- [ ] Cleanup
Expand All @@ -50,4 +53,15 @@ Under active development.
- Locked media should only have some attributes locked, if even necessary at all. (i.e. the queue isn't running multiple things at once)
- How does this affect search/navigation?

## Usage

You'll want to do three things when using this library in the app:

1. Setup logging to see the library's messages. (`tracing_subscriber`)
1. Make or load a configuration for the library. (`config::CONFIG`)
2. Use `database::DB_FOLDER_PATH.set(<path>)` to say where the database is (or will be) located.
3. Start the file watcher with `Watch::watch()`.

It's important that these tasks are performed **before** using the library. Otherwise, the backend will not be correctly initialized, and bugs may result.

<!-- cargo-rdme end -->
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// generated by `sqlx migrate build-script`
fn main() {
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed=migrations");
}
73 changes: 0 additions & 73 deletions examples/checking.rs

This file was deleted.

29 changes: 29 additions & 0 deletions examples/kamadak_dump_exif.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::env;
use std::fs::File;
use std::io::BufReader;
use std::path::{Path, PathBuf};

fn main() {
for path in env::args_os().skip(1).map(PathBuf::from) {
dump_file(&path);
}
}

fn dump_file(path: &Path) {
let file = File::open(path).unwrap();

// To parse with continue-on-error mode:
let exif = kamadak_exif::Reader::new()
.read_from_container(&mut BufReader::new(&file))
.unwrap();
println!("{}", path.display());
for f in exif.fields() {
println!(
" {}/{}: {}",
f.ifd_num.index(),
f.tag,
f.display_value().with_unit(&exif)
);
println!(" {:?}", f.value);
}
}
78 changes: 0 additions & 78 deletions examples/media.rs

This file was deleted.

27 changes: 15 additions & 12 deletions examples/query.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
//! Let's see if we can chain query method calls...

use std::ffi::OsString;

use backdrop::{
database::RavesDb,
models::{media::Media, metadata::types::Orientation},
database::DATABASE,
models::media::{
metadata::{Orientation, Resolution},
Media,
},
};
use camino::Utf8PathBuf;

#[tokio::main]
async fn main() {
let db = RavesDb::connect().await.unwrap();
let all: Vec<Media> = db.media_info.select("info").await.unwrap();
let mut conn = DATABASE.acquire().await.expect("db conn");
let all = sqlx::query_as::<_, Media>("SELECT * FROM info")
.fetch_all(&mut *conn)
.await
.unwrap();

// SEARCH: all media where:
// - orientation is portrait,
Expand All @@ -20,20 +25,18 @@ async fn main() {
.iter()
.filter(|m| {
matches!(
Orientation::from(m.metadata.resolution.clone()),
Orientation::from(Resolution::new(m.width_px, m.height_px)),
Orientation::Portrait
)
})
.filter(|m| {
m.metadata
.path
Utf8PathBuf::from(&m.path)
.file_name()
.unwrap_or(OsString::new().as_os_str())
.to_string_lossy()
.unwrap_or_default()
.to_string()
.contains(('0'..='9').collect::<Vec<_>>().as_slice())
})
.filter(|m| m.metadata.resolution.width > 1920 && m.metadata.resolution.height > 1080)
.filter(|m| m.width_px > 1920 && m.height_px > 1080)
.collect::<Vec<_>>();

println!("found results: {:#?}", executed_search);
Expand Down
Loading
Loading