mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-06 22:33:27 +00:00
prepare for prisma integration
Co-authored-by: Brendan Allan <brendonovich@outlook.com>
This commit is contained in:
parent
c95350c57f
commit
bfa43bb351
259
apps/desktop/src-tauri/Cargo.lock
generated
259
apps/desktop/src-tauri/Cargo.lock
generated
|
@ -470,6 +470,12 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.4.0"
|
||||
|
@ -610,6 +616,12 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
|
@ -895,6 +907,12 @@ dependencies = [
|
|||
"objc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.2"
|
||||
|
@ -1317,6 +1335,15 @@ dependencies = [
|
|||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "deflate"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "derivative"
|
||||
version = "2.2.0"
|
||||
|
@ -1567,6 +1594,22 @@ version = "2.5.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59"
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4badb9489a465cb2c555af1f00f0bfd8cecd6fc12ac11da9d5b40c5dd5f0200"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"deflate 1.0.0",
|
||||
"flume",
|
||||
"half",
|
||||
"inflate 0.4.5",
|
||||
"lebe",
|
||||
"smallvec",
|
||||
"threadpool",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
|
@ -1635,6 +1678,19 @@ dependencies = [
|
|||
"miniz_oxide 0.4.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
version = "0.10.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b279436a715a9de95dcd26b151db590a71961cc06e54918b24fe0dd5b7d3fc4"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"nanorand",
|
||||
"pin-project 1.0.10",
|
||||
"spin 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fnv"
|
||||
version = "1.0.7"
|
||||
|
@ -1961,8 +2017,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1975,6 +2033,16 @@ dependencies = [
|
|||
"polyval",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3a7187e78088aead22ceedeee99779455b23fc231fe13ec443f99bb71694e5b"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.26.1"
|
||||
|
@ -2169,6 +2237,12 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
|
@ -2402,6 +2476,26 @@ dependencies = [
|
|||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db207d030ae38f1eb6f240d5a1c1c88ff422aa005d10f8c6c6fc5e75286ab30e"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"color_quant",
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg-decoder 0.2.2",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"png 0.17.5",
|
||||
"scoped_threadpool",
|
||||
"tiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.7.0"
|
||||
|
@ -2430,6 +2524,15 @@ dependencies = [
|
|||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inflate"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.7.1"
|
||||
|
@ -2574,6 +2677,21 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2"
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "105fb082d64e2100074587f59a74231f771750c664af903f1f9f76c9dedfc6f1"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.55"
|
||||
|
@ -2643,6 +2761,12 @@ version = "1.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7efd1d698db0759e6ef11a7cd44407407399a910c774dd804c64c032da7826ff"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.112"
|
||||
|
@ -3246,6 +3370,15 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libwebp-sys"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439fd1885aa28937e7edcd68d2e793cb4a22f8733460d2519fbafd2b215672bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.3"
|
||||
|
@ -3399,6 +3532,12 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
|
@ -3430,6 +3569,15 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.6.23"
|
||||
|
@ -3538,6 +3686,15 @@ dependencies = [
|
|||
"unsigned-varint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nanorand"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "729eb334247daa1803e0a094d0a5c55711b85571179f5ec6e53eccfdf7008958"
|
||||
dependencies = [
|
||||
"getrandom 0.2.3",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "native-tls"
|
||||
version = "0.2.8"
|
||||
|
@ -3807,6 +3964,17 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
|
@ -4373,7 +4541,7 @@ checksum = "f0b0cabbbd20c2d7f06dbf015e06aad59b6ca3d9ed14848783e98af9aaf19925"
|
|||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"deflate 0.7.20",
|
||||
"inflate",
|
||||
"inflate 0.3.4",
|
||||
"num-iter",
|
||||
]
|
||||
|
||||
|
@ -4389,6 +4557,18 @@ dependencies = [
|
|||
"miniz_oxide 0.3.7",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
"deflate 1.0.0",
|
||||
"miniz_oxide 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "2.2.0"
|
||||
|
@ -4911,7 +5091,7 @@ dependencies = [
|
|||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin",
|
||||
"spin 0.5.2",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi 0.3.9",
|
||||
|
@ -4926,7 +5106,7 @@ dependencies = [
|
|||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin",
|
||||
"spin 0.5.2",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi 0.3.9",
|
||||
|
@ -5118,6 +5298,12 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
||||
|
||||
[[package]]
|
||||
name = "scoped_threadpool"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
|
@ -5163,6 +5349,7 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"libp2p",
|
||||
"log",
|
||||
"mime",
|
||||
"once_cell",
|
||||
"rebind",
|
||||
"refinery",
|
||||
|
@ -5175,6 +5362,7 @@ dependencies = [
|
|||
"sqlx",
|
||||
"strum 0.21.0",
|
||||
"swift-rs",
|
||||
"thumbnailer",
|
||||
"tokio",
|
||||
"ts-rs",
|
||||
"uuid",
|
||||
|
@ -5665,6 +5853,15 @@ version = "0.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlformat"
|
||||
version = "0.1.8"
|
||||
|
@ -6228,13 +6425,13 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.2.0"
|
||||
version = "3.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22"
|
||||
checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"fastrand",
|
||||
"libc",
|
||||
"rand 0.8.4",
|
||||
"redox_syscall 0.2.10",
|
||||
"remove_dir_all",
|
||||
"winapi 0.3.9",
|
||||
|
@ -6315,6 +6512,40 @@ dependencies = [
|
|||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "threadpool"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
|
||||
dependencies = [
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thumbnailer"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16c652b0061a3f3500284063fab527dc5e2dbd015905fcd08c5bd471c52a338b"
|
||||
dependencies = [
|
||||
"image",
|
||||
"lazy_static",
|
||||
"mime",
|
||||
"rayon",
|
||||
"tempfile",
|
||||
"webp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiff"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0247608e998cb6ce39dfc8f4a16c50361ce71e5b52e6d24ea1227ea8ea8ee0b2"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"jpeg-decoder 0.1.22",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.43"
|
||||
|
@ -6854,6 +7085,16 @@ dependencies = [
|
|||
"system-deps 5.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webp"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f80f6a431ea17cbe9d6958628e553c17d22df62b301b39940a9dfd60f3dd7c6"
|
||||
dependencies = [
|
||||
"image",
|
||||
"libwebp-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki"
|
||||
version = "0.21.4"
|
||||
|
@ -6929,6 +7170,12 @@ dependencies = [
|
|||
"windows-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e"
|
||||
|
||||
[[package]]
|
||||
name = "wepoll-ffi"
|
||||
version = "0.1.2"
|
||||
|
|
|
@ -2,8 +2,8 @@ use anyhow::Result;
|
|||
use sdcorelib::{
|
||||
core_send_stream,
|
||||
db::connection::db,
|
||||
file::{icon, indexer, locations, retrieve, retrieve::Directory, watcher::watch_dir},
|
||||
native,
|
||||
file::{icon, indexer, retrieve, retrieve::Directory, watcher::watch_dir},
|
||||
library, native,
|
||||
state::{client, client::ClientState},
|
||||
};
|
||||
use swift_rs::types::SRObjectArray;
|
||||
|
@ -49,6 +49,7 @@ pub async fn get_thumbs_for_directory(path: &str) -> Result<(), String> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn start_watcher(path: &str) -> Result<(), String> {
|
||||
println!("starting watcher for: {:?}", path);
|
||||
|
@ -59,6 +60,6 @@ pub async fn start_watcher(path: &str) -> Result<(), String> {
|
|||
|
||||
#[tauri::command]
|
||||
pub async fn create_location(path: &str) -> Result<(), String> {
|
||||
let _location = locations::create_location(path);
|
||||
let _location = library::locations::create_location(path);
|
||||
Ok(())
|
||||
}
|
||||
|
|
321
packages/core/Cargo.lock
generated
321
packages/core/Cargo.lock
generated
|
@ -23,6 +23,12 @@ version = "1.0.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
|
||||
|
||||
[[package]]
|
||||
name = "adler32"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234"
|
||||
|
||||
[[package]]
|
||||
name = "aead"
|
||||
version = "0.4.3"
|
||||
|
@ -379,7 +385,7 @@ dependencies = [
|
|||
"cc",
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
"miniz_oxide",
|
||||
"miniz_oxide 0.4.4",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
]
|
||||
|
@ -409,6 +415,12 @@ version = "0.6.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc0455254eb5c6964c4545d8bac815e1a1be4f3afe0ae695ea539c12d728d44b"
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "0.4.0"
|
||||
|
@ -508,6 +520,12 @@ version = "0.3.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e851ca7c24871e7336801608a4797d7376545b6928a10d32d75685687141ead"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.4.3"
|
||||
|
@ -683,6 +701,12 @@ dependencies = [
|
|||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "color_quant"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b"
|
||||
|
||||
[[package]]
|
||||
name = "combine"
|
||||
version = "4.6.3"
|
||||
|
@ -807,6 +831,30 @@ dependencies = [
|
|||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c00d6d2ea26e8b151d99093005cb442fb9a37aeaca582a03ec70946f49ab5ed9"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.4"
|
||||
|
@ -915,6 +963,15 @@ version = "2.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57"
|
||||
|
||||
[[package]]
|
||||
name = "deflate"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c86f7e25f518f4b81808a2cf1c50996a61f5c2eb394b2393bd87f2a4780a432f"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.8.1"
|
||||
|
@ -1082,6 +1139,22 @@ version = "2.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "77f3309417938f28bf8228fcff79a4a37103981e3e186d2ccd19c74b38f4eb71"
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d4badb9489a465cb2c555af1f00f0bfd8cecd6fc12ac11da9d5b40c5dd5f0200"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"deflate",
|
||||
"flume",
|
||||
"half",
|
||||
"inflate",
|
||||
"lebe",
|
||||
"smallvec",
|
||||
"threadpool",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fake-simd"
|
||||
version = "0.1.2"
|
||||
|
@ -1137,7 +1210,20 @@ dependencies = [
|
|||
"crc32fast",
|
||||
"libc",
|
||||
"libz-sys",
|
||||
"miniz_oxide",
|
||||
"miniz_oxide 0.4.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "flume"
|
||||
version = "0.10.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b279436a715a9de95dcd26b151db590a71961cc06e54918b24fe0dd5b7d3fc4"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"nanorand",
|
||||
"pin-project 1.0.10",
|
||||
"spin 0.9.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1361,8 +1447,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"js-sys",
|
||||
"libc",
|
||||
"wasi 0.10.2+wasi-snapshot-preview1",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -1375,6 +1463,16 @@ dependencies = [
|
|||
"polyval",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.11.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3a7187e78088aead22ceedeee99779455b23fc231fe13ec443f99bb71694e5b"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.26.1"
|
||||
|
@ -1414,6 +1512,12 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "1.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7"
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.9.1"
|
||||
|
@ -1576,6 +1680,26 @@ dependencies = [
|
|||
"windows",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.24.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db207d030ae38f1eb6f240d5a1c1c88ff422aa005d10f8c6c6fc5e75286ab30e"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"color_quant",
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg-decoder 0.2.2",
|
||||
"num-iter",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"png",
|
||||
"scoped_threadpool",
|
||||
"tiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.0"
|
||||
|
@ -1586,6 +1710,15 @@ dependencies = [
|
|||
"hashbrown 0.11.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inflate"
|
||||
version = "0.4.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1cdb29978cc5797bd8dcc8e5bf7de604891df2a8dc576973d71a281e916db2ff"
|
||||
dependencies = [
|
||||
"adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inotify"
|
||||
version = "0.7.1"
|
||||
|
@ -1701,6 +1834,21 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.1.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "229d53d58899083193af11e15917b5640cd40b29ff475a1fe4ef725deb02d0f2"
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "105fb082d64e2100074587f59a74231f771750c664af903f1f9f76c9dedfc6f1"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.56"
|
||||
|
@ -1758,6 +1906,12 @@ version = "1.3.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7efd1d698db0759e6ef11a7cd44407407399a910c774dd804c64c032da7826ff"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.117"
|
||||
|
@ -2361,6 +2515,15 @@ dependencies = [
|
|||
"vcpkg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libwebp-sys"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "439fd1885aa28937e7edcd68d2e793cb4a22f8733460d2519fbafd2b215672bf"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libz-sys"
|
||||
version = "1.1.3"
|
||||
|
@ -2449,6 +2612,12 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mime"
|
||||
version = "0.3.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d"
|
||||
|
||||
[[package]]
|
||||
name = "minimal-lexical"
|
||||
version = "0.2.1"
|
||||
|
@ -2465,6 +2634,15 @@ dependencies = [
|
|||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2b29bd4bc3f33391105ebee3589c19197c4271e3e5a9ec9bfe8127eeff8f082"
|
||||
dependencies = [
|
||||
"adler",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio"
|
||||
version = "0.6.23"
|
||||
|
@ -2573,6 +2751,15 @@ dependencies = [
|
|||
"unsigned-varint",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nanorand"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "729eb334247daa1803e0a094d0a5c55711b85571179f5ec6e53eccfdf7008958"
|
||||
dependencies = [
|
||||
"getrandom 0.2.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "net2"
|
||||
version = "0.2.37"
|
||||
|
@ -2718,6 +2905,28 @@ dependencies = [
|
|||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-iter"
|
||||
version = "0.1.42"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d41702bd167c2df5520b384281bc111a4b5efcf7fbc4c9c222c815b07e0a6a6a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.14"
|
||||
|
@ -3057,6 +3266,18 @@ version = "0.3.24"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe"
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.17.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc38c0ad57efb786dd57b9864e5b18bae478c00c824dc55a38bbc9da95dde3ba"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"crc32fast",
|
||||
"deflate",
|
||||
"miniz_oxide 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "polling"
|
||||
version = "2.2.0"
|
||||
|
@ -3333,6 +3554,31 @@ dependencies = [
|
|||
"rand_core 0.5.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"crossbeam-deque",
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e"
|
||||
dependencies = [
|
||||
"crossbeam-channel",
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
"lazy_static",
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rebind"
|
||||
version = "0.2.1"
|
||||
|
@ -3454,7 +3700,7 @@ dependencies = [
|
|||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin",
|
||||
"spin 0.5.2",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi 0.3.9",
|
||||
|
@ -3469,7 +3715,7 @@ dependencies = [
|
|||
"cc",
|
||||
"libc",
|
||||
"once_cell",
|
||||
"spin",
|
||||
"spin 0.5.2",
|
||||
"untrusted",
|
||||
"web-sys",
|
||||
"winapi 0.3.9",
|
||||
|
@ -3624,6 +3870,12 @@ dependencies = [
|
|||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "scoped_threadpool"
|
||||
version = "0.1.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8"
|
||||
|
||||
[[package]]
|
||||
name = "scopeguard"
|
||||
version = "1.1.0"
|
||||
|
@ -3669,6 +3921,7 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"libp2p",
|
||||
"log",
|
||||
"mime",
|
||||
"once_cell",
|
||||
"rebind",
|
||||
"refinery",
|
||||
|
@ -3681,6 +3934,7 @@ dependencies = [
|
|||
"sqlx",
|
||||
"strum",
|
||||
"swift-rs",
|
||||
"thumbnailer",
|
||||
"tokio",
|
||||
"ts-rs",
|
||||
"uuid",
|
||||
|
@ -4016,6 +4270,15 @@ version = "0.5.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d"
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "511254be0c5bcf062b019a6c89c01a664aa359ded62f78aa72c6fc137c0590e5"
|
||||
dependencies = [
|
||||
"lock_api",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlformat"
|
||||
version = "0.1.8"
|
||||
|
@ -4324,6 +4587,40 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "threadpool"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
|
||||
dependencies = [
|
||||
"num_cpus",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thumbnailer"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "16c652b0061a3f3500284063fab527dc5e2dbd015905fcd08c5bd471c52a338b"
|
||||
dependencies = [
|
||||
"image",
|
||||
"lazy_static",
|
||||
"mime",
|
||||
"rayon",
|
||||
"tempfile",
|
||||
"webp",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiff"
|
||||
version = "0.7.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0247608e998cb6ce39dfc8f4a16c50361ce71e5b52e6d24ea1227ea8ea8ee0b2"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"jpeg-decoder 0.1.22",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.1.43"
|
||||
|
@ -4774,6 +5071,16 @@ dependencies = [
|
|||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webp"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f80f6a431ea17cbe9d6958628e553c17d22df62b301b39940a9dfd60f3dd7c6"
|
||||
dependencies = [
|
||||
"image",
|
||||
"libwebp-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki"
|
||||
version = "0.21.4"
|
||||
|
@ -4812,6 +5119,12 @@ dependencies = [
|
|||
"webpki 0.22.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d8b77fdfd5a253be4ab714e4ffa3c49caf146b4de743e97510c0656cf90f1e8e"
|
||||
|
||||
[[package]]
|
||||
name = "wepoll-ffi"
|
||||
version = "0.1.2"
|
||||
|
|
|
@ -6,13 +6,6 @@ authors = ["NerdHouse, Inc.", "Jamie Pine"]
|
|||
license = ""
|
||||
repository = "https://github.com/jamiepine/spacedrive"
|
||||
edition = "2018"
|
||||
include = ["lib/**/*.rs"]
|
||||
|
||||
[lib]
|
||||
name = "sdcorelib"
|
||||
# crate-type = ["cdylib"]
|
||||
# bench = false
|
||||
path = "lib/main.rs"
|
||||
|
||||
[dependencies]
|
||||
swift-rs = "0.2.3"
|
||||
|
@ -47,5 +40,7 @@ libp2p = "0.43.0"
|
|||
config = {version = "0.12", features = ["toml"]}
|
||||
lazy_static = "1.4.0"
|
||||
uuid = "0.8"
|
||||
thumbnailer = "0.4.0"
|
||||
mime = "0.3.16"
|
||||
|
||||
tokio = {version = "1.15.0", features=["sync"]}
|
|
@ -1,16 +0,0 @@
|
|||
// use sea_orm::entity::prelude::*;
|
||||
// use serde::{Deserialize, Serialize};
|
||||
// use ts_rs::TS;
|
||||
|
||||
// #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, EnumIter, DeriveActiveEnum, TS)]
|
||||
// #[sea_orm(rs_type = "i32", db_type = "Integer")]
|
||||
// pub enum Encryption {
|
||||
// #[sea_orm(num_value = 0)]
|
||||
// None,
|
||||
// #[sea_orm(num_value = 1)]
|
||||
// AES128,
|
||||
// #[sea_orm(num_value = 2)]
|
||||
// AES192,
|
||||
// #[sea_orm(num_value = 3)]
|
||||
// AES256,
|
||||
// }
|
|
@ -1,28 +0,0 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub enum Action {
|
||||
SCAN_DIR,
|
||||
ENCRYPT_FILE,
|
||||
UPLOAD_FILE,
|
||||
}
|
||||
|
||||
// A job is triggered by a user interaction or schedule
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Job {
|
||||
pub id: String,
|
||||
pub client_id: String,
|
||||
pub storage_device_id: Option<String>,
|
||||
pub uri: Option<String>,
|
||||
pub action: Action,
|
||||
pub status: String,
|
||||
pub complete: bool,
|
||||
}
|
||||
|
||||
// // A task is a way to track the completion of a portion of a job
|
||||
// // usually specific
|
||||
// #[derive(Serialize, Deserialize)]
|
||||
// pub struct Task {
|
||||
// pub id: String,
|
||||
// pub job_id: String,
|
||||
// }
|
|
@ -1,10 +0,0 @@
|
|||
pub struct Job {
|
||||
pub id: i32,
|
||||
pub timestamp: i32,
|
||||
pub client_id: i32,
|
||||
pub target_client_id: i32,
|
||||
pub file_id: i32,
|
||||
pub action: Action,
|
||||
pub status: String,
|
||||
pub complete: bool,
|
||||
}
|
|
@ -1,32 +0,0 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Shard {
|
||||
pub shard_type: ShardType,
|
||||
pub client_id: u32,
|
||||
pub library_id: u32,
|
||||
pub timestamp: DateTime<Utc>,
|
||||
pub sql: Option<String>,
|
||||
}
|
||||
|
||||
enum ShardType {
|
||||
Create,
|
||||
Mutate,
|
||||
Delete,
|
||||
}
|
||||
|
||||
impl Shard {
|
||||
pub fn new(shard_type: ShardType, sql: Option<String>) -> Self {
|
||||
Self { shard_type, sql }
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// example
|
||||
Shard::new(
|
||||
ShardType::Mutate,
|
||||
file::Model::update_many()
|
||||
.set(pear)
|
||||
.filter(file::Column::Id.eq(1)),
|
||||
);
|
||||
}
|
140
packages/core/prisma/schema.prisma
Normal file
140
packages/core/prisma/schema.prisma
Normal file
|
@ -0,0 +1,140 @@
|
|||
datasource db {
|
||||
provider = "sqlite"
|
||||
url = "file:/Users/jamie/Library/Application Support/spacedrive/library.db"
|
||||
}
|
||||
|
||||
model Library {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String
|
||||
name String
|
||||
remote_id String?
|
||||
is_primary Boolean @default(true)
|
||||
encryption Int @default(0)
|
||||
total_file_count Int @default(0)
|
||||
total_bytes_used String @default("0")
|
||||
total_byte_capacity String @default("0")
|
||||
total_unique_bytes String @default("0")
|
||||
date_created DateTime @default(now())
|
||||
timezone String?
|
||||
spaces Space[]
|
||||
|
||||
@@map("libraries")
|
||||
}
|
||||
|
||||
model Client {
|
||||
id Int @id @default(autoincrement())
|
||||
uuid String @unique()
|
||||
name String
|
||||
platform Int @default(0)
|
||||
online Boolean? @default(true)
|
||||
last_seen DateTime @default(now())
|
||||
timezone String?
|
||||
date_created DateTime @default(now())
|
||||
jobs Job[]
|
||||
|
||||
@@map("clients")
|
||||
}
|
||||
|
||||
model Location {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
path String?
|
||||
total_capacity Int?
|
||||
available_capacity Int?
|
||||
is_removable Boolean @default(true)
|
||||
is_ejectable Boolean @default(true)
|
||||
is_root_filesystem Boolean @default(true)
|
||||
is_online Boolean @default(true)
|
||||
date_created DateTime @default(now())
|
||||
files File[]
|
||||
|
||||
@@map("locations")
|
||||
}
|
||||
|
||||
model File {
|
||||
id Int @id @default(autoincrement())
|
||||
is_dir Boolean @default(false)
|
||||
meta_integrity_hash String @unique()
|
||||
sampled_byte_integrity_hash String?
|
||||
byte_integrity_hash String?
|
||||
name String?
|
||||
extension String?
|
||||
size_in_bytes String
|
||||
encryption Int @default(0)
|
||||
ipfs_id String?
|
||||
date_created DateTime @default(now())
|
||||
date_modified DateTime @default(now())
|
||||
date_indexed DateTime @default(now())
|
||||
location_id Int?
|
||||
directory_id Int?
|
||||
capture_device_id Int?
|
||||
parent_id Int?
|
||||
capture_devices CaptureDevice? @relation(fields: [capture_device_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
locations Location? @relation(fields: [location_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
files File? @relation("file_to_file_parent_id", fields: [parent_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
other_files File[] @relation("file_to_file_parent_id")
|
||||
tags_files TagFile[] @ignore
|
||||
|
||||
@@map("files")
|
||||
}
|
||||
|
||||
model Tag {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
encryption Int? @default(0)
|
||||
total_files Int? @default(0)
|
||||
redundancy_goal Int? @default(1)
|
||||
date_created DateTime @default(now())
|
||||
date_modified DateTime @default(now())
|
||||
tags_files TagFile[] @ignore
|
||||
|
||||
@@map("tags")
|
||||
}
|
||||
|
||||
model TagFile {
|
||||
tag_id Int
|
||||
file_id Int
|
||||
date_created DateTime @default(now())
|
||||
file File @relation(fields: [file_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
tag Tag @relation(fields: [tag_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@id([tag_id, file_id])
|
||||
@@map("tags_files")
|
||||
}
|
||||
|
||||
model Job {
|
||||
id Int @id @default(autoincrement())
|
||||
client_id Int
|
||||
action Int
|
||||
status Int @default(0)
|
||||
percentage_complete Int @default(0)
|
||||
task_count Int @default(1)
|
||||
completed_task_count Int @default(0)
|
||||
date_created DateTime @default(now())
|
||||
date_modified DateTime @default(now())
|
||||
clients Client @relation(fields: [client_id], references: [id], onDelete: NoAction, onUpdate: NoAction)
|
||||
|
||||
@@map("jobs")
|
||||
}
|
||||
|
||||
model Space {
|
||||
id Int @id @default(autoincrement())
|
||||
name String
|
||||
encryption Int? @default(0)
|
||||
date_created DateTime @default(now())
|
||||
date_modified DateTime @default(now())
|
||||
|
||||
Library Library? @relation(fields: [libraryId], references: [id])
|
||||
libraryId Int?
|
||||
@@map("spaces")
|
||||
}
|
||||
|
||||
model CaptureDevice {
|
||||
id Int @id @default(autoincrement())
|
||||
name String?
|
||||
date_created DateTime @default(now())
|
||||
date_modified DateTime @default(now())
|
||||
files File[]
|
||||
|
||||
@@map("capture_devices")
|
||||
}
|
11
packages/core/src/crypto/encryption.rs
Normal file
11
packages/core/src/crypto/encryption.rs
Normal file
|
@ -0,0 +1,11 @@
|
|||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, EnumIter, TS)]
|
||||
pub enum Encryption {
|
||||
None = 0,
|
||||
AES128,
|
||||
AES192,
|
||||
AES256,
|
||||
}
|
|
@ -38,7 +38,7 @@ pub async fn init(db_url: &str) -> Result<(), sqlx::Error> {
|
|||
// migrate db
|
||||
mod embedded_primary {
|
||||
use refinery::embed_migrations;
|
||||
embed_migrations!("lib/db/migrations");
|
||||
embed_migrations!("src/db/migrations");
|
||||
}
|
||||
|
||||
embedded_primary::migrations::runner()
|
|
@ -15,27 +15,29 @@ pub struct Model {
|
|||
// identity
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: u32,
|
||||
#[ts(type = "json")]
|
||||
pub materialized_path: Json,
|
||||
#[sea_orm(nullable)]
|
||||
pub parent_id: Option<u32>,
|
||||
// pub buffer_checksum: String,
|
||||
#[sea_orm(unique)]
|
||||
pub meta_integrity_hash: String,
|
||||
pub sampled_byte_integrity_hash: Option<String>,
|
||||
pub byte_integrity_hash: Option<String>,
|
||||
|
||||
pub uri: String,
|
||||
// pub uri: String,
|
||||
pub is_dir: bool,
|
||||
// metadata
|
||||
pub name: String,
|
||||
pub extension: String,
|
||||
pub size_in_bytes: String,
|
||||
pub library_id: u32,
|
||||
// date
|
||||
#[ts(type = "string")]
|
||||
pub date_created: Option<NaiveDateTime>,
|
||||
#[ts(type = "string")]
|
||||
pub date_modified: Option<NaiveDateTime>,
|
||||
#[ts(type = "string")]
|
||||
pub date_indexed: Option<NaiveDateTime>,
|
||||
|
||||
// #[ts(type = "string")]
|
||||
// pub date_indexed: Option<NaiveDateTime>,
|
||||
pub encryption: Encryption,
|
||||
// ownership
|
||||
#[sea_orm(nullable)]
|
||||
|
@ -46,9 +48,6 @@ pub struct Model {
|
|||
|
||||
#[sea_orm(nullable)]
|
||||
pub capture_device_id: Option<u32>,
|
||||
|
||||
#[sea_orm(nullable)]
|
||||
pub parent_id: Option<u32>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, EnumIter, DeriveActiveEnum, TS)]
|
||||
|
@ -67,13 +66,6 @@ pub enum Encryption {
|
|||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::library::Entity",
|
||||
from = "Column::LibraryId",
|
||||
to = "super::library::Column::Id"
|
||||
)]
|
||||
Library,
|
||||
|
||||
#[sea_orm(
|
||||
belongs_to = "super::locations::Entity",
|
||||
from = "Column::LocationId",
|
70
packages/core/src/db/entity/job.rs
Normal file
70
packages/core/src/db/entity/job.rs
Normal file
|
@ -0,0 +1,70 @@
|
|||
use chrono::NaiveDateTime;
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ts_rs::TS;
|
||||
|
||||
// -------------------------------------
|
||||
// Entity: Job
|
||||
//
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, DeriveEntityModel, TS)]
|
||||
#[sea_orm(table_name = "jobs")]
|
||||
#[serde(rename = "Job")]
|
||||
#[ts(export)]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
pub id: u32,
|
||||
// the client that will perform this task
|
||||
pub client_id: u32,
|
||||
// what kind of task is this
|
||||
pub action: Action,
|
||||
// status
|
||||
pub status: Status,
|
||||
pub percentage_complete: u32,
|
||||
pub task_count: u32,
|
||||
pub completed_task_count: u32,
|
||||
|
||||
#[ts(type = "string")]
|
||||
pub date_created: Option<NaiveDateTime>,
|
||||
#[ts(type = "string")]
|
||||
pub date_modified: Option<NaiveDateTime>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, EnumIter, DeriveActiveEnum, TS)]
|
||||
#[sea_orm(rs_type = "u32", db_type = "Integer")]
|
||||
#[ts(export)]
|
||||
pub enum Action {
|
||||
#[sea_orm(num_value = 0)]
|
||||
Scan,
|
||||
#[sea_orm(num_value = 1)]
|
||||
Encrypt,
|
||||
#[sea_orm(num_value = 2)]
|
||||
Upload,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, EnumIter, DeriveActiveEnum, TS)]
|
||||
#[sea_orm(rs_type = "u32", db_type = "Integer")]
|
||||
#[ts(export)]
|
||||
pub enum Status {
|
||||
#[sea_orm(num_value = 0)]
|
||||
Queued,
|
||||
#[sea_orm(num_value = 1)]
|
||||
InProgress,
|
||||
#[sea_orm(num_value = 2)]
|
||||
Cancelled,
|
||||
#[sea_orm(num_value = 3)]
|
||||
Completed,
|
||||
#[sea_orm(num_value = 4)]
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||
pub enum Relation {
|
||||
#[sea_orm(
|
||||
belongs_to = "super::client::Entity",
|
||||
from = "Column::ClientId",
|
||||
to = "super::client::Column::Id"
|
||||
)]
|
||||
Client,
|
||||
}
|
||||
|
||||
impl ActiveModelBehavior for ActiveModel {}
|
|
@ -1,7 +1,7 @@
|
|||
pub mod capture_device;
|
||||
// pub mod dir;
|
||||
pub mod client;
|
||||
pub mod file;
|
||||
pub mod job;
|
||||
pub mod library;
|
||||
pub mod locations;
|
||||
pub mod space;
|
|
@ -33,12 +33,11 @@ CREATE TABLE IF NOT EXISTS locations (
|
|||
is_ejectable BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
is_root_filesystem BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
is_online BOOLEAN NOT NULL DEFAULT TRUE,
|
||||
date_created DATE NOT NULL DEFAULT (datetime('now')),
|
||||
last_indexed DATE NOT NULL DEFAULT (datetime('now'))
|
||||
date_created DATE NOT NULL DEFAULT (datetime('now')) -- last_indexed DATE NOT NULL DEFAULT (datetime('now'))
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS files (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
uri TEXT NOT NULL,
|
||||
-- uri TEXT NOT NULL,
|
||||
is_dir BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
meta_integrity_hash TEXT NOT NULL UNIQUE ON CONFLICT IGNORE,
|
||||
sampled_byte_integrity_hash TEXT,
|
||||
|
@ -51,16 +50,26 @@ CREATE TABLE IF NOT EXISTS files (
|
|||
date_created DATE NOT NULL DEFAULT (datetime('now')),
|
||||
date_modified DATE NOT NULL DEFAULT (datetime('now')),
|
||||
date_indexed DATE NOT NULL DEFAULT (datetime('now')),
|
||||
library_id INTEGER NOT NULL,
|
||||
location_id INTEGER,
|
||||
directory_id INTEGER,
|
||||
capture_device_id INTEGER,
|
||||
parent_id INTEGER,
|
||||
FOREIGN KEY(library_id) REFERENCES libraries(id),
|
||||
FOREIGN KEY(parent_id) REFERENCES files(id),
|
||||
FOREIGN KEY(location_id) REFERENCES locations(id),
|
||||
FOREIGN KEY(capture_device_id) REFERENCES capture_devices(id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS jobs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
client_id INTEGER NOT NULL,
|
||||
action INTEGER NOT NULL,
|
||||
status INTEGER NOT NULL DEFAULT 0,
|
||||
percentage_complete INTEGER NOT NULL DEFAULT 0,
|
||||
task_count INTEGER NOT NULL DEFAULT 1,
|
||||
completed_task_count INTEGER NOT NULL DEFAULT 0,
|
||||
date_created DATE NOT NULL DEFAULT (datetime('now')),
|
||||
date_modified DATE NOT NULL DEFAULT (datetime('now')),
|
||||
FOREIGN KEY(client_id) REFERENCES clients(id)
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS tags (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
name TEXT,
|
|
@ -27,7 +27,8 @@ pub async fn get_thumbs_for_directory(path: &str) -> impl Stream<Item = ClientEv
|
|||
// write thumbnail only if
|
||||
if !existing {
|
||||
// call swift to get thumbnail data
|
||||
let thumbnail_b64 = native::methods::get_file_thumbnail_base64(&file.uri).to_string();
|
||||
let thumbnail_b64 =
|
||||
native::methods::get_file_thumbnail_base64(&file.meta_integrity_hash).to_string();
|
||||
fs::write(
|
||||
&icon_path,
|
||||
base64::decode(thumbnail_b64).unwrap_or_default(),
|
|
@ -7,10 +7,9 @@ use walkdir::{DirEntry, WalkDir};
|
|||
|
||||
use crate::db::{connection::db, entity::file};
|
||||
use crate::file::checksum::create_meta_integrity_hash;
|
||||
use crate::library;
|
||||
use crate::library::locations::get_location;
|
||||
use crate::util::time;
|
||||
|
||||
use super::locations::get_location;
|
||||
use super::watcher::watch_dir;
|
||||
|
||||
pub async fn scan_paths(location_id: u32) -> Result<()> {
|
||||
|
@ -26,7 +25,7 @@ pub async fn scan_paths(location_id: u32) -> Result<()> {
|
|||
// creates a vector of valid path buffers from a directory
|
||||
pub async fn scan(path: &str) -> Result<()> {
|
||||
println!("Scanning directory: {}", &path);
|
||||
let current_library = library::loader::get().await?;
|
||||
// let current_library = library::loader::get().await?;
|
||||
|
||||
let db = db().await.unwrap();
|
||||
|
||||
|
@ -50,14 +49,15 @@ pub async fn scan(path: &str) -> Result<()> {
|
|||
}
|
||||
|
||||
// store every valid path discovered
|
||||
let mut paths: Vec<(PathBuf, u32, Option<u32>, u32)> = Vec::new();
|
||||
let mut paths: Vec<(PathBuf, u32, Option<u32>)> = Vec::new();
|
||||
// store a hashmap of directories to their file ids for fast lookup
|
||||
let mut dirs: HashMap<String, u32> = HashMap::new();
|
||||
// begin timer for logging purposes
|
||||
let scan_start = Instant::now();
|
||||
// walk through directory recursively
|
||||
for entry in WalkDir::new(path).into_iter().filter_entry(|dir| {
|
||||
let approved = !is_hidden(dir) && !is_app_bundle(dir) && !is_node_modules(dir);
|
||||
let approved =
|
||||
!is_hidden(dir) && !is_app_bundle(dir) && !is_node_modules(dir) && !is_library(dir);
|
||||
approved
|
||||
}) {
|
||||
// extract directory entry or log and continue if failed
|
||||
|
@ -79,12 +79,7 @@ pub async fn scan(path: &str) -> Result<()> {
|
|||
println!("Discovered: {:?}, {:?}", &path, &parent_dir_id);
|
||||
|
||||
let file_id = get_id();
|
||||
paths.push((
|
||||
path.to_owned(),
|
||||
file_id,
|
||||
parent_dir_id.cloned(),
|
||||
current_library.id,
|
||||
));
|
||||
paths.push((path.to_owned(), file_id, parent_dir_id.cloned()));
|
||||
|
||||
if entry.file_type().is_dir() {
|
||||
let _path = match path.to_str() {
|
||||
|
@ -101,7 +96,7 @@ pub async fn scan(path: &str) -> Result<()> {
|
|||
println!("Writing {} files to db at chunk {}", chunk.len(), i);
|
||||
// vector to store active models
|
||||
let mut files: Vec<file::ActiveModel> = Vec::new();
|
||||
for (file_path, file_id, parent_dir_id, library_id) in chunk {
|
||||
for (file_path, file_id, parent_dir_id) in chunk {
|
||||
// TODO: add location
|
||||
files.push(
|
||||
match create_active_file_model(
|
||||
|
@ -109,7 +104,6 @@ pub async fn scan(path: &str) -> Result<()> {
|
|||
&file_id,
|
||||
parent_dir_id.as_ref(),
|
||||
path, // TODO: we'll need the location path directly from location object just in case we're re-scanning a portion
|
||||
library_id.clone(),
|
||||
) {
|
||||
Ok(file) => file,
|
||||
Err(e) => {
|
||||
|
@ -144,7 +138,6 @@ fn create_active_file_model(
|
|||
id: &u32,
|
||||
parent_id: Option<&u32>,
|
||||
location_path: &str,
|
||||
library_id: u32,
|
||||
) -> Result<file::ActiveModel> {
|
||||
let metadata = fs::metadata(&uri)?;
|
||||
let size = metadata.len();
|
||||
|
@ -152,20 +145,6 @@ fn create_active_file_model(
|
|||
create_meta_integrity_hash(uri.to_str().unwrap_or_default(), size)?;
|
||||
meta_integrity_hash.truncate(20);
|
||||
|
||||
let mut location_relative_uri = uri
|
||||
.to_str()
|
||||
.unwrap()
|
||||
.split(location_path)
|
||||
.last()
|
||||
.unwrap()
|
||||
.to_owned();
|
||||
|
||||
// if location_relative_uri is empty String return "/"
|
||||
location_relative_uri = match location_relative_uri.is_empty() {
|
||||
true => "/".to_owned(),
|
||||
false => location_relative_uri,
|
||||
};
|
||||
|
||||
Ok(file::ActiveModel {
|
||||
id: Set(*id),
|
||||
is_dir: Set(metadata.is_dir()),
|
||||
|
@ -174,12 +153,11 @@ fn create_active_file_model(
|
|||
name: Set(extract_name(uri.file_stem())),
|
||||
extension: Set(extract_name(uri.extension())),
|
||||
encryption: Set(file::Encryption::None),
|
||||
uri: Set(location_relative_uri),
|
||||
library_id: Set(library_id),
|
||||
// uri: Set(location_relative_uri),
|
||||
size_in_bytes: Set(size.to_string()),
|
||||
date_created: Set(Some(time::system_time_to_date_time(metadata.created())?)),
|
||||
date_modified: Set(Some(time::system_time_to_date_time(metadata.modified())?)),
|
||||
date_indexed: Set(Some(Utc::now().naive_utc())),
|
||||
// date_indexed: Set(Some(Utc::now().naive_utc())),
|
||||
..Default::default()
|
||||
})
|
||||
}
|
||||
|
@ -212,6 +190,15 @@ fn is_hidden(entry: &DirEntry) -> bool {
|
|||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn is_library(entry: &DirEntry) -> bool {
|
||||
entry
|
||||
.path()
|
||||
.to_str()
|
||||
// make better this is shit
|
||||
.map(|s| s.contains("/Library/"))
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
fn is_node_modules(entry: &DirEntry) -> bool {
|
||||
entry
|
||||
.file_name()
|
|
@ -1,6 +1,6 @@
|
|||
pub mod checksum;
|
||||
pub mod icon;
|
||||
pub mod indexer;
|
||||
pub mod locations;
|
||||
pub mod retrieve;
|
||||
pub mod thumb;
|
||||
pub mod watcher;
|
|
@ -17,7 +17,7 @@ pub async fn get_dir_with_contents(path: &str) -> Result<Directory, String> {
|
|||
println!("getting files... {:?}", &path);
|
||||
|
||||
let directories = file::Entity::find()
|
||||
.filter(file::Column::Uri.eq(path))
|
||||
.filter(file::Column::Name.eq(path)) // FIXXXXX
|
||||
.all(connection)
|
||||
.await
|
||||
.map_err(|e| e.to_string())?;
|
22
packages/core/src/file/thumb.rs
Normal file
22
packages/core/src/file/thumb.rs
Normal file
|
@ -0,0 +1,22 @@
|
|||
use anyhow::Result;
|
||||
use mime;
|
||||
use std::fs::File;
|
||||
use std::io::BufReader;
|
||||
use std::io::Cursor;
|
||||
use thumbnailer::{create_thumbnails, ThumbnailSize};
|
||||
|
||||
pub async fn create_thumb(path: &str) -> Result<()> {
|
||||
let file = File::open(path).unwrap();
|
||||
let reader = BufReader::new(file);
|
||||
|
||||
let mut thumbnails =
|
||||
create_thumbnails(reader, mime::IMAGE_PNG, [ThumbnailSize::Small]).unwrap();
|
||||
|
||||
let thumbnail = thumbnails.pop().unwrap();
|
||||
|
||||
let mut buf = Cursor::new(Vec::new());
|
||||
|
||||
thumbnail.write_png(&mut buf).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
9
packages/core/src/job/create.rs
Normal file
9
packages/core/src/job/create.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
use db::entity;
|
||||
|
||||
struct QueueItem {
|
||||
job: entity::job::Model,
|
||||
}
|
||||
|
||||
pub async fn queue() {
|
||||
|
||||
}
|
|
@ -1,11 +1,3 @@
|
|||
use futures::executor::block_on;
|
||||
use futures::{stream::StreamExt, Stream};
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use tokio::sync::mpsc;
|
||||
use ts_rs::TS;
|
||||
|
||||
pub mod crypto;
|
||||
pub mod db;
|
||||
pub mod file;
|
||||
|
@ -15,7 +7,15 @@ pub mod state;
|
|||
// pub mod p2p;
|
||||
pub mod util;
|
||||
|
||||
use crate::state::client::ClientState;
|
||||
use futures::executor::block_on;
|
||||
use futures::{stream::StreamExt, Stream};
|
||||
use once_cell::sync::OnceCell;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::fs;
|
||||
use tokio::sync::mpsc;
|
||||
use ts_rs::TS;
|
||||
|
||||
use state::client::ClientState;
|
||||
|
||||
// represents an event this library can emit
|
||||
#[derive(Serialize, Deserialize, Debug, TS)]
|
|
@ -1,3 +1,4 @@
|
|||
pub mod client;
|
||||
// pub mod init;
|
||||
pub mod loader;
|
||||
pub mod locations;
|
|
@ -1,6 +1,6 @@
|
|||
use async_std::task;
|
||||
use libp2p::{identity, Multiaddr, PeerId, ping};
|
||||
use libp2p::swarm::{Swarm, SwarmEvent};
|
||||
use lib::p2p::{identity, Multiaddr, PeerId, ping};
|
||||
use lib::p2p::swarm::{Swarm, SwarmEvent};
|
||||
use std::error::Error;
|
||||
|
||||
pub async fn listen(port: Option<u32>) -> Result<(), Box<dyn Error>> {
|
|
@ -6,7 +6,7 @@ use std::io::{BufReader, Write};
|
|||
use std::sync::RwLock;
|
||||
use uuid::Uuid;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
pub struct ClientState {
|
||||
// client id is a uniquely generated UUID
|
||||
pub client_id: String,
|
||||
|
@ -22,38 +22,15 @@ pub struct ClientState {
|
|||
pub current_library_id: String,
|
||||
}
|
||||
|
||||
pub static CLIENT_STATE_CONFIG_NAME: &str = ".client_state";
|
||||
pub static CLIENT_STATE_CONFIG_NAME: &str = "client_state.json";
|
||||
|
||||
impl Default for ClientState {
|
||||
fn default() -> Self {
|
||||
ClientState {
|
||||
client_id: "".to_string(),
|
||||
data_path: "".to_string(),
|
||||
client_name: "".to_string(),
|
||||
tcp_port: 0,
|
||||
libraries: vec![],
|
||||
current_library_id: "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
|
||||
pub struct LibraryState {
|
||||
pub library_id: String,
|
||||
pub library_path: String,
|
||||
pub offline: bool,
|
||||
}
|
||||
|
||||
impl Default for LibraryState {
|
||||
fn default() -> Self {
|
||||
LibraryState {
|
||||
library_id: "".to_string(),
|
||||
library_path: "".to_string(),
|
||||
offline: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// global, thread-safe storage for client state
|
||||
lazy_static! {
|
||||
static ref CONFIG: RwLock<Option<ClientState>> = RwLock::new(None);
|
||||
|
@ -104,10 +81,8 @@ impl ClientState {
|
|||
}
|
||||
|
||||
fn write_memory(&self) {
|
||||
{
|
||||
let mut writeable = CONFIG.write().unwrap();
|
||||
*writeable = Some(self.clone());
|
||||
}
|
||||
let mut writeable = CONFIG.write().unwrap();
|
||||
*writeable = Some(self.clone());
|
||||
}
|
||||
|
||||
pub fn get_current_library(&self) -> LibraryState {
|
52
packages/core/src/tx/commit.rs
Normal file
52
packages/core/src/tx/commit.rs
Normal file
|
@ -0,0 +1,52 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
pub struct Commit {
|
||||
pub commit_type: CommitType,
|
||||
pub client_id: u32,
|
||||
pub library_id: u32,
|
||||
pub timestamp: DateTime<Utc>,
|
||||
pub sql: Option<String>,
|
||||
}
|
||||
|
||||
enum CommitType {
|
||||
Create,
|
||||
Mutate,
|
||||
Delete,
|
||||
}
|
||||
|
||||
impl Commit {
|
||||
pub fn new(commit_type: CommitType, sql: Option<String>) -> Self {
|
||||
Self { commit_type, sql }
|
||||
}
|
||||
|
||||
pub fn from_query<T: SerializeQuery>(query: T) -> Self {
|
||||
Self::new(CommitType::Mutate, query.serialize_query())
|
||||
}
|
||||
}
|
||||
|
||||
struct RawQuery(String);
|
||||
|
||||
trait SerializeQuery {
|
||||
fn serialize_query(self) -> String;
|
||||
}
|
||||
|
||||
struct PostFindMany {
|
||||
query: String,
|
||||
}
|
||||
|
||||
impl SerializeQuery for PostFindUnique {
|
||||
fn serialize_query(self) -> String {
|
||||
RawQuery(self.query)
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// example
|
||||
Commit::from_query(
|
||||
client
|
||||
.post()
|
||||
.find_unique(Post::id().equals("post0".to_string()))
|
||||
.with(vec![Post::user().fetch()]),
|
||||
);
|
||||
}
|
1
packages/core/src/tx/resolve.rs
Normal file
1
packages/core/src/tx/resolve.rs
Normal file
|
@ -0,0 +1 @@
|
|||
pub fn get_locations() {}
|
Loading…
Reference in a new issue