diff --git a/.drone/drone.jsonnet b/.drone/drone.jsonnet new file mode 100644 index 0000000..3727e1a --- /dev/null +++ b/.drone/drone.jsonnet @@ -0,0 +1,36 @@ +local deploy() = { + name: "publish", + kind: "pipeline", + type: "docker", + trigger: {branch: ["main"]}, + steps: [ + { + name: "run-tests", + image: "proget.makedeb.org/docker/makedeb/makedeb:ubuntu-kinetic", + commands: [ + "sudo chown 'makedeb:makedeb' ./ -R", + ".drone/scripts/run-tests.sh" + ] + }, + + { + name: "create-release", + image: "proget.makedeb.org/docker/makedeb/makedeb:ubuntu-kinetic", + environment: { + github_api_key: {from_secret: "github_api_key"} + }, + commands: [".drone/scripts/create-release.sh"] + }, + + { + name: "publish-mpr", + image: "proget.makedeb.org/docker/makedeb/makedeb:ubuntu-jammy", + environment: { + ssh_key: {from_secret: "ssh_key"} + }, + commands: [".drone/scripts/publish-mpr.sh"] + } + ] +}; + +[deploy()] diff --git a/.drone/scripts/create-release.sh b/.drone/scripts/create-release.sh new file mode 100755 index 0000000..19fbfe0 --- /dev/null +++ b/.drone/scripts/create-release.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +set -ex + +# Set up the PBMPR. +.drone/scripts/setup-pbmpr.sh + +# Install needed dependencies. +sudo apt-get install appimage-builder gh git jq just parse-changelog -y +.drone/scripts/install-pkgbuild-deps.sh + +# Create the appimage. +just create-appimage + +# Create the release. +pkgver="$(just get-version)" +release_notes="$(parse-changelog CHANGELOG.md "${pkgver}")" +echo "${github_api_key}" | gh auth login --with-token +gh release create "v${pkgver}" --title "v${pkgver}" --target "${DRONE_COMMIT_SHA}" -n "${release_notes}" "celeste.AppImage#celeste-${pkgver}.AppImage" + +# vim: set sw=4 expandtab: diff --git a/.drone/scripts/install-pkgbuild-deps.sh b/.drone/scripts/install-pkgbuild-deps.sh new file mode 100755 index 0000000..04320d7 --- /dev/null +++ b/.drone/scripts/install-pkgbuild-deps.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +set -e + +cd makedeb/ +cp PKGBUILD PKGBUILD.OLD + +echo -e '\npackage() { true; }' >> PKGBUILD +sed -i -e 's|source=.*||' -e 's|sha256sums=.*||' PKGBUILD +makedeb -s --no-build --no-check --no-confirm + +rm PKGBUILD +mv PKGBUILD.OLD PKGBUILD \ No newline at end of file diff --git a/.drone/scripts/publish-mpr.sh b/.drone/scripts/publish-mpr.sh new file mode 100755 index 0000000..8d592a3 --- /dev/null +++ b/.drone/scripts/publish-mpr.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -ex + +sudo apt install curl jq git -y +curl -Ls "https://shlink.${hw_url}/ci-utils" | sudo bash - + +mkdir ~/.ssh +echo -e "Host ${mpr_url}\n Hostname ${mpr_url}\n IdentityFile ${HOME}/.ssh/ssh_key" | tee -a "${HOME}/.ssh/config" +echo "${ssh_key}" | tee "/${HOME}/.ssh/ssh_key" + +MPR_SSH_KEY="$(curl "https://${mpr_url}/api/meta" | jq -r '.ssh_key_fingerprints.ECDSA')" + +SSH_HOST="${mpr_url}" \ + SSH_EXPECTED_FINGERPRINT="${MPR_SSH_KEY}" \ + SET_PERMS=true \ + get-ssh-key + +cd makedeb/ +source PKGBUILD + +git clone "ssh://mpr@${mpr_url}/${pkgname}" +cp PKGBUILD mist.postinst "${pkgname}/" +cd "${pkgname}/" + +git config --global user.name 'Kavplex Bot' +git config --global user.email 'kavplex@hunterwittenborn.com' + +makedeb --print-srcinfo | tee .SRCINFO +git add . +git commit -m "Bump version to '${pkgver}-${pkgrel}'" +git push \ No newline at end of file diff --git a/.drone/scripts/run-tests.sh b/.drone/scripts/run-tests.sh new file mode 100755 index 0000000..81be953 --- /dev/null +++ b/.drone/scripts/run-tests.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +set -ex + +.drone/scripts/setup-pbmpr.sh +.drone/scripts/install-pkgbuild-deps.sh + +cargo fmt --check +cargo clippy -- -D warnings + +# vim: set sw=4 expandtab: diff --git a/.drone/scripts/setup-pbmpr.sh b/.drone/scripts/setup-pbmpr.sh new file mode 100755 index 0000000..fd8c650 --- /dev/null +++ b/.drone/scripts/setup-pbmpr.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash +curl -q 'https://proget.makedeb.org/debian-feeds/prebuilt-mpr.pub' | gpg --dearmor | sudo tee /usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg 1> /dev/null +echo "deb [signed-by=/usr/share/keyrings/prebuilt-mpr-archive-keyring.gpg] https://proget.makedeb.org prebuilt-mpr $(lsb_release -cs)" | sudo tee /etc/apt/sources.list.d/prebuilt-mpr.list +sudo apt-get update diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..de7a0ff --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/AppDir +/AppDir.squashfs +/celeste.AppImage +/celeste.AppImage.zsync +/appimage-build +/target +/style.css \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..0615b32 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +## [0.1.0] - 2022-12-28 +First release! 🥳 \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..c27cd9e --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3363 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "aliasable" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "ansi_term" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2" +dependencies = [ + "winapi", +] + +[[package]] +name = "anyhow" +version = "1.0.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6" + +[[package]] +name = "arrayvec" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8da52d66c7071e2e3fa2a1e5c6d088fec47b593032b254f5e980de8ea54454d6" + +[[package]] +name = "async-channel" +version = "1.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +dependencies = [ + "concurrent-queue 1.2.4", + "event-listener", + "futures-core", +] + +[[package]] +name = "async-executor" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" +dependencies = [ + "async-lock", + "async-task", + "concurrent-queue 2.0.0", + "fastrand", + "futures-lite", + "slab", +] + +[[package]] +name = "async-global-executor" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1b6f5d7df27bd294849f8eec66ecfc63d11814df7a4f5d74168a2394467b776" +dependencies = [ + "async-channel", + "async-executor", + "async-io", + "async-lock", + "blocking", + "futures-lite", + "once_cell", +] + +[[package]] +name = "async-io" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" +dependencies = [ + "async-lock", + "autocfg", + "concurrent-queue 2.0.0", + "futures-lite", + "libc", + "log", + "parking", + "polling", + "slab", + "socket2", + "waker-fn", + "windows-sys", +] + +[[package]] +name = "async-lock" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8101efe8695a6c17e02911402145357e718ac92d3ff88ae8419e84b1707b685" +dependencies = [ + "event-listener", + "futures-lite", +] + +[[package]] +name = "async-process" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6381ead98388605d0d9ff86371043b5aa922a3905824244de40dc263a14fcba4" +dependencies = [ + "async-io", + "async-lock", + "autocfg", + "blocking", + "cfg-if", + "event-listener", + "futures-lite", + "libc", + "signal-hook", + "windows-sys", +] + +[[package]] +name = "async-std" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62565bb4402e926b29953c785397c6dc0391b7b446e45008b0049eb43cec6f5d" +dependencies = [ + "async-channel", + "async-global-executor", + "async-io", + "async-lock", + "async-process", + "crossbeam-utils", + "futures-channel", + "futures-core", + "futures-io", + "futures-lite", + "gloo-timers", + "kv-log-macro", + "log", + "memchr", + "once_cell", + "pin-project-lite", + "pin-utils", + "slab", + "wasm-bindgen-futures", +] + +[[package]] +name = "async-stream" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dad5c83079eae9969be7fadefe640a1c566901f05ff91ab221de4b6f68d9507e" +dependencies = [ + "async-stream-impl", + "futures-core", +] + +[[package]] +name = "async-stream-impl" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f203db73a71dfa2fb6dd22763990fa26f3d2625a6da2da900d23b87d26be27" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "async-task" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" + +[[package]] +name = "async-trait" +version = "0.1.59" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "atoi" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c57d12312ff59c811c0643f4d80830505833c9ffaebd193d819392b265be8e" +dependencies = [ + "num-traits", +] + +[[package]] +name = "atomic-waker" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi 0.1.19", + "libc", + "winapi", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "bae" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b8de67cc41132507eeece2584804efcb15f85ba516e34c944b7667f480397a" +dependencies = [ + "heck 0.3.3", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "base64" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" + +[[package]] +name = "base64" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" + +[[package]] +name = "beef" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a8241f3ebb85c056b509d4327ad0358fbbba6ffb340bf388f26350aeda225b1" + +[[package]] +name = "bindgen" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36d860121800b2a9a94f9b5604b332d5cffb234ce17609ea479d723dbc9d3885" +dependencies = [ + "bitflags", + "cexpr", + "clang-sys", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn", + "which", +] + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "block-buffer" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cce20737498f97b993470a6e536b8523f0af7892a4f928cceb1ac5e52ebe7e" +dependencies = [ + "generic-array", +] + +[[package]] +name = "blocking" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c67b173a56acffd6d2326fb7ab938ba0b00a71480e14902b2591c87bc5741e8" +dependencies = [ + "async-channel", + "async-lock", + "async-task", + "atomic-waker", + "fastrand", + "futures-lite", +] + +[[package]] +name = "borsh" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15bf3650200d8bffa99015595e10f1fbd17de07abbc25bb067da79e769939bfa" +dependencies = [ + "borsh-derive", + "hashbrown 0.11.2", +] + +[[package]] +name = "borsh-derive" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6441c552f230375d18e3cc377677914d2ca2b0d36e52129fe15450a2dce46775" +dependencies = [ + "borsh-derive-internal", + "borsh-schema-derive-internal", + "proc-macro-crate 0.1.5", + "proc-macro2", + "syn", +] + +[[package]] +name = "borsh-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5449c28a7b352f2d1e592a8a28bf139bc71afb0764a14f3c02500935d8c44065" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "borsh-schema-derive-internal" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdbd5696d8bfa21d53d9fe39a714a18538bad11492a42d066dbbc395fb1951c0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "bumpalo" +version = "3.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572f695136211188308f16ad2ca5c851a712c464060ae6974944458eb83880ba" + +[[package]] +name = "bytecheck" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d11cac2c12b5adc6570dad2ee1b87eff4955dac476fe12d81e5fdd352e52406f" +dependencies = [ + "bytecheck_derive", + "ptr_meta", +] + +[[package]] +name = "bytecheck_derive" +version = "0.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13e576ebe98e605500b3c8041bb888e966653577172df6dd97398714eb30b9bf" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "byteorder" +version = "1.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" + +[[package]] +name = "bytes" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" + +[[package]] +name = "cache-padded" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" + +[[package]] +name = "cairo-rs" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "247e1183fa769ac22121f92276dae52f89acaf297f24b1320019f439b6e3b46f" +dependencies = [ + "bitflags", + "cairo-sys-rs", + "glib", + "libc", + "once_cell", + "thiserror", +] + +[[package]] +name = "cairo-sys-rs" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c48f4af05fabdcfa9658178e1326efa061853f040ce7d72e33af6885196f421" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "cc" +version = "1.0.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4" + +[[package]] +name = "celeste" +version = "0.1.0" +dependencies = [ + "base64 0.20.0", + "blocking", + "clap 4.0.29", + "dirs", + "exitcode", + "file-lock", + "futures", + "glob", + "grass", + "hw-msg", + "indexmap", + "libadwaita", + "librclone", + "quit", + "rand", + "regex", + "sea-orm", + "sea-orm-migration", + "serde", + "serde_json", + "time", + "tokio", + "toml_edit", + "url", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-expr" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0357a6402b295ca3a86bc148e84df46c02e41f41fef186bda662557ef6328aa" +dependencies = [ + "smallvec", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "chrono" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b0a3d9ed01224b22057780a37bb8c5dbfe1be8ba48678e7bf57ec4b385411f" +dependencies = [ + "iana-time-zone", + "num-integer", + "num-traits", + "serde", + "winapi", +] + +[[package]] +name = "clang-sys" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa2e27ae6ab525c3d369ded447057bca5438d86dc3a68f6faafb8269ba82ebf3" +dependencies = [ + "glob", + "libc", + "libloading", +] + +[[package]] +name = "clap" +version = "2.34.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim 0.8.0", + "textwrap 0.11.0", + "unicode-width", + "vec_map", +] + +[[package]] +name = "clap" +version = "3.2.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +dependencies = [ + "atty", + "bitflags", + "clap_derive 3.2.18", + "clap_lex 0.2.4", + "indexmap", + "once_cell", + "strsim 0.10.0", + "termcolor", + "textwrap 0.16.0", +] + +[[package]] +name = "clap" +version = "4.0.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d63b9e9c07271b9957ad22c173bae2a4d9a81127680962039296abcd2f8251d" +dependencies = [ + "bitflags", + "clap_derive 4.0.21", + "clap_lex 0.3.0", + "is-terminal", + "once_cell", + "strsim 0.10.0", + "termcolor", +] + +[[package]] +name = "clap_derive" +version = "3.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea0c8bce528c4be4da13ea6fead8965e95b6073585a2f05204bd8f4119f82a65" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_derive" +version = "4.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014" +dependencies = [ + "heck 0.4.0", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "clap_lex" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d4198f73e42b4936b35b5bb248d81d2b595ecb170da0bac7655c54eedfa8da8" +dependencies = [ + "os_str_bytes", +] + +[[package]] +name = "codemap" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e769b5c8c8283982a987c6e948e540254f1058d5a74b8794914d4ef5fc2a24" + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "colored" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3616f750b84d8f0de8a58bda93e08e2a81ad3f523089b05f1dffecab48c6cbd" +dependencies = [ + "atty", + "lazy_static", + "winapi", +] + +[[package]] +name = "combine" +version = "4.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35ed6e9d84f0b51a7f52daf1c7d71dd136fd7a3f41a8462b8cdb8c78d920fad4" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "1.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" +dependencies = [ + "cache-padded", +] + +[[package]] +name = "concurrent-queue" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd7bef69dc86e3c610e4e7aed41035e2a7ed12e72dd7530f61327a6579a4390b" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" + +[[package]] +name = "cpufeatures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d997bd5e24a5928dd43e46dc529867e207907fe0b239c3477d924f7f2ca320" +dependencies = [ + "libc", +] + +[[package]] +name = "crc" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53757d12b596c16c78b83458d732a5d1a17ab3f53f2f7412f6fb57cc8a140ab3" +dependencies = [ + "crc-catalog", +] + +[[package]] +name = "crc-catalog" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d0165d2900ae6778e36e80bbc4da3b5eefccee9ba939761f9c2882a5d9af3ff" + +[[package]] +name = "crossbeam-queue" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1cfb3ea8a53f37c40dea2c7bedcbd88bdfae54f5e2175d6ecaff1c988353add" +dependencies = [ + "cfg-if", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fb766fa798726286dbbb842f174001dab8abc7b627a1dd86e0b7222a95d929f" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crypto-common" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3" +dependencies = [ + "generic-array", + "typenum", +] + +[[package]] +name = "ctor" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d2301688392eb071b0bf1a37be05c469d3cc4dbbd95df672fe28ab021e6a096" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "cxx" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf07d07d6531bfcdbe9b8b739b104610c6508dcc4d63b410585faf338241daf" +dependencies = [ + "cc", + "cxxbridge-flags", + "cxxbridge-macro", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2eb5b96ecdc99f72657332953d4d9c50135af1bac34277801cc3937906ebd39" +dependencies = [ + "cc", + "codespan-reporting", + "once_cell", + "proc-macro2", + "quote", + "scratch", + "syn", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac040a39517fd1674e0f32177648334b0f4074625b5588a64519804ba0553b12" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1362b0ddcfc4eb0a1f57b68bd77dd99f0e826958a96abd0ae9bd092e114ffed6" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "digest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +dependencies = [ + "block-buffer", + "crypto-common", +] + +[[package]] +name = "dirs" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" +dependencies = [ + "libc", + "redox_users", + "winapi", +] + +[[package]] +name = "dotenvy" +version = "0.15.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03d8c417d7a8cb362e0c37e5d815f5eb7c37f79ff93707329d5a194e42e54ca0" + +[[package]] +name = "either" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" + +[[package]] +name = "errno" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "event-listener" +version = "2.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0" + +[[package]] +name = "exitcode" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de853764b47027c2e862a995c34978ffa63c1501f2e15f987ba11bd4f9bba193" + +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + +[[package]] +name = "field-offset" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e1c54951450cbd39f3dbcf1005ac413b49487dabf18a720ad2383eccfeffb92" +dependencies = [ + "memoffset", + "rustc_version", +] + +[[package]] +name = "file-lock" +version = "2.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0815fc2a1924e651b71ae6d13df07b356a671a09ecaf857dbd344a2ba937a496" +dependencies = [ + "cc", + "libc", + "mktemp", + "nix", +] + +[[package]] +name = "flume" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1657b4441c3403d9f7b3409e47575237dac27b1b5726df654a6ecbf92f0f7577" +dependencies = [ + "futures-core", + "futures-sink", + "pin-project", + "spin 0.9.4", +] + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38390104763dc37a5145a53c29c63c1290b5d316d6086ec32c293f6736051bb0" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-channel" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52ba265a92256105f45b719605a571ffe2d1f0fea3807304b522c1d778f79eed" +dependencies = [ + "futures-core", + "futures-sink", +] + +[[package]] +name = "futures-core" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04909a7a7e4633ae6c4a9ab280aeb86da1236243a77b694a49eacd659a4bd3ac" + +[[package]] +name = "futures-executor" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7acc85df6714c176ab5edf386123fafe217be88c0840ec11f199441134a074e2" +dependencies = [ + "futures-core", + "futures-task", + "futures-util", +] + +[[package]] +name = "futures-intrusive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a604f7a68fbf8103337523b1fadc8ade7361ee3f112f7c680ad179651616aed5" +dependencies = [ + "futures-core", + "lock_api", + "parking_lot", +] + +[[package]] +name = "futures-io" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f5fb52a06bdcadeb54e8d3671f8888a39697dcb0b81b23b55174030427f4eb" + +[[package]] +name = "futures-lite" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" +dependencies = [ + "fastrand", + "futures-core", + "futures-io", + "memchr", + "parking", + "pin-project-lite", + "waker-fn", +] + +[[package]] +name = "futures-macro" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdfb8ce053d86b91919aad980c220b1fb8401a9394410e1c289ed7e66b61835d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-rustls" +version = "0.22.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2411eed028cdf8c8034eaf21f9915f956b6c3abec4d4c7949ee67f0721127bd" +dependencies = [ + "futures-io", + "rustls", + "webpki", +] + +[[package]] +name = "futures-sink" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39c15cf1a4aa79df40f1bb462fb39676d0ad9e366c2a33b590d7c66f4f81fcf9" + +[[package]] +name = "futures-task" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ffb393ac5d9a6eaa9d3fdf37ae2776656b706e200c8e16b1bdb227f5198e6ea" + +[[package]] +name = "futures-util" +version = "0.3.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "197676987abd2f9cadff84926f410af1c183608d36641465df73ae8211dc65d6" +dependencies = [ + "futures-channel", + "futures-core", + "futures-io", + "futures-macro", + "futures-sink", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "gdk-pixbuf" +version = "0.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3094f2b8578136d1929cade4e0fff82f573521b579e96cfc24af2458431f176" +dependencies = [ + "bitflags", + "gdk-pixbuf-sys", + "gio", + "glib", + "libc", +] + +[[package]] +name = "gdk-pixbuf-sys" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3092cf797a5f1210479ea38070d9ae8a5b8e9f8f1be9f32f4643c529c7d70016" +dependencies = [ + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "gdk4" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "237d840e2017e61a8f528261e3397f378b579aeb8c7b798b29bbec6d4890c843" +dependencies = [ + "bitflags", + "cairo-rs", + "gdk-pixbuf", + "gdk4-sys", + "gio", + "glib", + "libc", + "pango", +] + +[[package]] +name = "gdk4-sys" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b5dafeabcbabda52b39b28e0641c5767d56cd47f273291d1bf1bb846176a6a0" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "libc", + "pango-sys", + "pkg-config", + "system-deps", +] + +[[package]] +name = "generic-array" +version = "0.14.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bff49e947297f3312447abdca79f45f4738097cc82b06e72054d2223f601f1b9" +dependencies = [ + "typenum", + "version_check", +] + +[[package]] +name = "getrandom" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c05aeb6a22b8f62540c194aac980f2115af067bfe15a0734d7277a768d396b31" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "gio" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d4a17d999e6e4e05d87c2bb05b7140d47769bc53211711a33e2f91536458714" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-io", + "futures-util", + "gio-sys", + "glib", + "libc", + "once_cell", + "pin-project-lite", + "smallvec", + "thiserror", +] + +[[package]] +name = "gio-sys" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e9b693b8e39d042a95547fc258a7b07349b1f0b48f4b2fa3108ba3c51c0b5229" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", + "winapi", +] + +[[package]] +name = "glib" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cd04d150a2c63e6779f43aec7e04f5374252479b7bed5f45146d9c0e821f161" +dependencies = [ + "bitflags", + "futures-channel", + "futures-core", + "futures-executor", + "futures-task", + "futures-util", + "gio-sys", + "glib-macros", + "glib-sys", + "gobject-sys", + "libc", + "once_cell", + "smallvec", + "thiserror", +] + +[[package]] +name = "glib-macros" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e084807350b01348b6d9dbabb724d1a0bb987f47a2c85de200e98e12e30733bf" +dependencies = [ + "anyhow", + "heck 0.4.0", + "proc-macro-crate 1.2.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "glib-sys" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61a4f46316d06bfa33a7ac22df6f0524c8be58e3db2d9ca99ccb1f357b62a65" +dependencies = [ + "libc", + "system-deps", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "gloo-timers" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98c4a8d6391675c6b2ee1a6c8d06e8e2d03605c44cec1270675985a4c2a5500b" +dependencies = [ + "futures-channel", + "futures-core", + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "gobject-sys" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3520bb9c07ae2a12c7f2fbb24d4efc11231c8146a86956413fb1a79bb760a0f1" +dependencies = [ + "glib-sys", + "libc", + "system-deps", +] + +[[package]] +name = "graphene-rs" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ecb4d347e6d09820df3bdfd89a74a8eec07753a06bb92a3aac3ad31d04447b" +dependencies = [ + "glib", + "graphene-sys", + "libc", +] + +[[package]] +name = "graphene-sys" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9aa82337d3972b4eafdea71e607c23f47be6f27f749aab613f1ad8ddbe6dcd6" +dependencies = [ + "glib-sys", + "libc", + "pkg-config", + "system-deps", +] + +[[package]] +name = "grass" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5bedc3dbd71dcdd41900e1f58e4d431fa69dd67c04ae1f86ae1a0339edd849" +dependencies = [ + "beef", + "clap 2.34.0", + "codemap", + "indexmap", + "lasso", + "num-bigint", + "num-rational", + "num-traits", + "once_cell", + "phf", + "rand", +] + +[[package]] +name = "gsk4" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e349ef4df495fe0e3ed926294bace13dc560ac97fe0943c6646349fd4208d9ca" +dependencies = [ + "bitflags", + "cairo-rs", + "gdk4", + "glib", + "graphene-rs", + "gsk4-sys", + "libc", + "pango", +] + +[[package]] +name = "gsk4-sys" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0118e5fcfbcb8dbd16b50dc79781c1cd520f1cf620c09a973d08023ca89d719" +dependencies = [ + "cairo-sys-rs", + "gdk4-sys", + "glib-sys", + "gobject-sys", + "graphene-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "gtk4" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2568accd16cfbeecaf961bd762d88888ee9f4bb161ab5d5cfc9517d62bdb4155" +dependencies = [ + "bitflags", + "cairo-rs", + "field-offset", + "futures-channel", + "gdk-pixbuf", + "gdk4", + "gio", + "glib", + "graphene-rs", + "gsk4", + "gtk4-macros", + "gtk4-sys", + "libc", + "once_cell", + "pango", +] + +[[package]] +name = "gtk4-macros" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ed8c00535fa1cb4b6d0e6548b0077148076c5ed8d46fc6e685cff5ee635529f" +dependencies = [ + "anyhow", + "proc-macro-crate 1.2.1", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "gtk4-sys" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bc9fe486789d3a43c1e2bf9f547964ec0181e5df5b9cdc214f88d335f8257ed" +dependencies = [ + "cairo-sys-rs", + "gdk-pixbuf-sys", + "gdk4-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "graphene-sys", + "gsk4-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashlink" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69fe1fcf8b4278d860ad0548329f892a3631fb63f82574df68275f34cdbe0ffa" +dependencies = [ + "hashbrown 0.12.3", +] + +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "heck" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" +dependencies = [ + "unicode-segmentation", +] + +[[package]] +name = "hermit-abi" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hex" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" + +[[package]] +name = "hw-msg" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "230fa1c73aa7e828cc0c89b6902340a2df9a42aa2a0e361f47acc5c2374c1660" +dependencies = [ + "colored", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64c122667b287044802d6ce17ee2ddf13207ed924c712de9a66a5814d5b64765" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "wasm-bindgen", + "winapi", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0703ae284fc167426161c2e3f1da3ea71d94b21bedbcc9494e92b28e334e3dca" +dependencies = [ + "cxx", + "cxx-build", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" +dependencies = [ + "autocfg", + "hashbrown 0.12.3", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46112a93252b123d31a119a8d1a1ac19deac4fac6e0e8b0df58f0d4e5870e63c" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "is-terminal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "927609f78c2913a6f6ac3c27a4fe87f43e2a35367c0c4b0f8265e8f49a104330" +dependencies = [ + "hermit-abi 0.2.6", + "io-lifetimes", + "rustix", + "windows-sys", +] + +[[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4217ad341ebadf8d8e724e264f13e593e0648f5b3e94b3896a5df283be015ecc" + +[[package]] +name = "js-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49409df3e3bf0856b916e2ceaca09ee28e6871cf7d9ce97a692cacfdb2a25a47" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "kv-log-macro" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" +dependencies = [ + "log", +] + +[[package]] +name = "lasso" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8647c8a01e5f7878eacb2c323c4c949fdb63773110f0686c7810769874b7e0a" +dependencies = [ + "hashbrown 0.11.2", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libadwaita" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dfa0722d4f1724f661cbf668c273c5926296ca411ed3814e206f8fd082b6c48" +dependencies = [ + "bitflags", + "futures-channel", + "gdk-pixbuf", + "gdk4", + "gio", + "glib", + "gtk4", + "libadwaita-sys", + "libc", + "once_cell", + "pango", +] + +[[package]] +name = "libadwaita-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "de902982372b454a0081d7fd9dd567b37b73ae29c8f6da1820374d345fd95d5b" +dependencies = [ + "gdk4-sys", + "gio-sys", + "glib-sys", + "gobject-sys", + "gtk4-sys", + "libc", + "pango-sys", + "system-deps", +] + +[[package]] +name = "libc" +version = "0.2.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "librclone" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "692d85a1b2e4409e42d60602930466bbc1db2e374ad3612c8a08a466b6626396" +dependencies = [ + "librclone-sys", +] + +[[package]] +name = "librclone-sys" +version = "0.3.0+rclone-v1.61.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6616403540b3931df213a1609c8c066a19b5e78c12e149ef71bfa56167578086" +dependencies = [ + "bindgen", +] + +[[package]] +name = "libsqlite3-sys" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "link-cplusplus" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9272ab7b96c9046fbc5bc56c06c117cb639fe2d509df0c421cad82d2915cf369" +dependencies = [ + "cc", +] + +[[package]] +name = "linux-raw-sys" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f" + +[[package]] +name = "lock_api" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "435011366fe56583b16cf956f9df0095b405b82d76425bc8981c0e22e60ec4df" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", + "value-bag", +] + +[[package]] +name = "matchers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8263075bb86c5a1b1427b5ae862e8889656f126e9f77c484496e8b47cf5c5558" +dependencies = [ + "regex-automata", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "memoffset" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa361d4faea93603064a027415f07bd8e1d5c88c9fbf68bf56a285428fd79ce" +dependencies = [ + "autocfg", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "mktemp" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "975de676448231fcde04b9149d2543077e166b78fc29eae5aa219e7928410da2" +dependencies = [ + "uuid 0.8.2", +] + +[[package]] +name = "nix" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa52e972a9a719cecb6864fb88568781eb706bac2cd1d4f04a648542dbf78069" +dependencies = [ + "bitflags", + "cfg-if", + "libc", +] + +[[package]] +name = "nom" +version = "7.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8903e5a29a317527874d0402f867152a3d21c908bb0b933e416c65e301d4c36" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "nu-ansi-term" +version = "0.46.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84" +dependencies = [ + "overload", + "winapi", +] + +[[package]] +name = "num-bigint" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93ab6289c7b344a8a9f60f88d80aa20032336fe78da341afc91c8a2341fc75f" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-integer" +version = "0.1.45" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "225d3389fb3509a24c93f5c29eb6bde2586b98d9f016636dff58d7c6f7569cd9" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0638a1c9d0a3c0914158145bc76cff373a75a627e6ecbfb71cbe6f453a5a19b0" +dependencies = [ + "autocfg", + "num-bigint", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578ede34cf02f8924ab9447f50c28075b4d3e5b269972345e7e0372b38c6cdcd" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6058e64324c71e02bc2b150e4f3bc8286db6c83092132ffa3f6b1eab0f9def5" +dependencies = [ + "hermit-abi 0.1.19", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860" + +[[package]] +name = "os_str_bytes" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee" + +[[package]] +name = "ouroboros" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbb50b356159620db6ac971c6d5c9ab788c9cc38a6f49619fca2a27acb062ca" +dependencies = [ + "aliasable", + "ouroboros_macro", +] + +[[package]] +name = "ouroboros_macro" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0d9d1a6191c4f391f87219d1ea42b23f09ee84d64763cd05ee6ea88d9f384d" +dependencies = [ + "Inflector", + "proc-macro-error", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "overload" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" + +[[package]] +name = "pango" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdff66b271861037b89d028656184059e03b0b6ccb36003820be19f7200b1e94" +dependencies = [ + "bitflags", + "gio", + "glib", + "libc", + "once_cell", + "pango-sys", +] + +[[package]] +name = "pango-sys" +version = "0.16.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e134909a9a293e04d2cc31928aa95679c5e4df954d0b85483159bd20d8f047f" +dependencies = [ + "glib-sys", + "gobject-sys", + "libc", + "system-deps", +] + +[[package]] +name = "parking" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" + +[[package]] +name = "parking_lot" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" +dependencies = [ + "cfg-if", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi", +] + +[[package]] +name = "paste" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1de2e551fb905ac83f73f7aedf2f0cb4a0da7e35efa24a202a936269f1f18e1" + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pest" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f400b0f7905bf702f9f3dc3df5a121b16c54e9e8012c082905fdf09a931861a" +dependencies = [ + "thiserror", + "ucd-trie", +] + +[[package]] +name = "phf" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ac8b67553a7ca9457ce0e526948cad581819238f4a9d1ea74545851fa24f37" +dependencies = [ + "phf_macros", + "phf_shared", + "proc-macro-hack", +] + +[[package]] +name = "phf_generator" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d43f3220d96e0080cc9ea234978ccd80d904eafb17be31bb0f76daaea6493082" +dependencies = [ + "phf_shared", + "rand", +] + +[[package]] +name = "phf_macros" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b706f5936eb50ed880ae3009395b43ed19db5bff2ebd459c95e7bf013a89ab86" +dependencies = [ + "phf_generator", + "phf_shared", + "proc-macro-hack", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "phf_shared" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a68318426de33640f02be62b4ae8eb1261be2efbc337b60c54d845bf4484e0d9" +dependencies = [ + "siphasher", +] + +[[package]] +name = "pin-project" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad29a609b6bcd67fee905812e544992d216af9d755757c05ed2d0e15a74c6ecc" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "polling" +version = "2.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "166ca89eb77fd403230b9c156612965a81e094ec6ec3aa13663d4c8b113fa748" +dependencies = [ + "autocfg", + "cfg-if", + "libc", + "log", + "wepoll-ffi", + "windows-sys", +] + +[[package]] +name = "ppv-lite86" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro-crate" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda0fc3b0fb7c975631757e14d9049da17374063edb6ebbcbc54d880d4fe94e9" +dependencies = [ + "once_cell", + "thiserror", + "toml", +] + +[[package]] +name = "proc-macro-error" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" +dependencies = [ + "proc-macro-error-attr", + "proc-macro2", + "quote", + "syn", + "version_check", +] + +[[package]] +name = "proc-macro-error-attr" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" +dependencies = [ + "proc-macro2", + "quote", + "version_check", +] + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "ptr_meta" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0738ccf7ea06b608c10564b31debd4f5bc5e197fc8bfe088f68ae5ce81e7a4f1" +dependencies = [ + "ptr_meta_derive", +] + +[[package]] +name = "ptr_meta_derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16b845dbfca988fa33db069c0e230574d15a3088f147a87b64c7589eb662c9ac" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "quit" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bad314fc86f60b58587ffaf97e3150ed6f0aece74012db9cf0e36ee88768e49d" +dependencies = [ + "quit_macros", +] + +[[package]] +name = "quit_macros" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a411616b47dce3139c0169c89899ba5ea3534e545ab4d0c1d3956460fe781bae" + +[[package]] +name = "quote" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom", +] + +[[package]] +name = "redox_syscall" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fb5a58c1855b4b6819d59012155603f0b22ad30cad752600aadfcb695265519a" +dependencies = [ + "bitflags", +] + +[[package]] +name = "redox_users" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" +dependencies = [ + "getrandom", + "redox_syscall", + "thiserror", +] + +[[package]] +name = "regex" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e076559ef8e241f2ae3479e36f97bd5741c0330689e217ad51ce2c76808b868a" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" +dependencies = [ + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" + +[[package]] +name = "rend" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79af64b4b6362ffba04eef3a4e10829718a4896dac19daa741851c86781edf95" +dependencies = [ + "bytecheck", +] + +[[package]] +name = "ring" +version = "0.16.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3053cf52e236a3ed746dfc745aa9cacf1b791d846bdaf412f60a8d7d6e17c8fc" +dependencies = [ + "cc", + "libc", + "once_cell", + "spin 0.5.2", + "untrusted", + "web-sys", + "winapi", +] + +[[package]] +name = "rkyv" +version = "0.7.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cec2b3485b07d96ddfd3134767b8a447b45ea4eb91448d0a35180ec0ffd5ed15" +dependencies = [ + "bytecheck", + "hashbrown 0.12.3", + "ptr_meta", + "rend", + "rkyv_derive", + "seahash", +] + +[[package]] +name = "rkyv_derive" +version = "0.7.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eaedadc88b53e36dd32d940ed21ae4d850d5916f2581526921f553a72ac34c4" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "rust_decimal" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33c321ee4e17d2b7abe12b5d20c1231db708dd36185c8a21e9de5fed6da4dbe9" +dependencies = [ + "arrayvec", + "borsh", + "bytecheck", + "byteorder", + "bytes", + "num-traits", + "rand", + "rkyv", + "serde", + "serde_json", +] + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver", +] + +[[package]] +name = "rustix" +version = "0.36.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rustls" +version = "0.20.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "539a2bfe908f471bfa933876bd1eb6a19cf2176d375f82ef7f99530a40e48c2c" +dependencies = [ + "log", + "ring", + "sct", + "webpki", +] + +[[package]] +name = "rustls-pemfile" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" +dependencies = [ + "base64 0.13.1", +] + +[[package]] +name = "rustversion" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97477e48b4cf8603ad5f7aaf897467cf42ab4218a38ef76fb14c2d6773a6d6a8" + +[[package]] +name = "ryu" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4501abdff3ae82a1c1b477a17252eb69cee9e66eb915c1abaa4f44d873df9f09" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "scratch" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8132065adcfd6e02db789d9285a0deb2f3fcb04002865ab67d5fb103533898" + +[[package]] +name = "sct" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d53dcdb7c9f8158937a7981b48accfd39a43af418591a5d008c7b22b5e1b7ca4" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "sea-orm" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28fc9dad132e450d6320bd5953e70fb88b42785080b591e9be804da69bd8a170" +dependencies = [ + "async-stream", + "async-trait", + "chrono", + "futures", + "futures-util", + "log", + "ouroboros", + "rust_decimal", + "sea-orm-macros", + "sea-query", + "sea-query-binder", + "sea-strum", + "serde", + "serde_json", + "sqlx", + "thiserror", + "time", + "tracing", + "url", + "uuid 1.2.2", +] + +[[package]] +name = "sea-orm-cli" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d037d297869f0960e56f49b6e8c427660f9cc9c3f867132f4d1014676525dbe7" +dependencies = [ + "chrono", + "clap 3.2.23", + "dotenvy", + "regex", + "sea-schema", + "tracing", + "tracing-subscriber", + "url", +] + +[[package]] +name = "sea-orm-macros" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66af5d33e04e56dafb2c700f9b1201a39e6c2c77b53ed9ee93244f21f8de6041" +dependencies = [ + "bae", + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sea-orm-migration" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5260d4956cb6ccf49654e6b94ff8030cd8778240627e971cb5a569347b61606" +dependencies = [ + "async-trait", + "clap 3.2.23", + "dotenvy", + "sea-orm", + "sea-orm-cli", + "sea-schema", + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "sea-query" +version = "0.27.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4f0fc4d8e44e1d51c739a68d336252a18bc59553778075d5e32649be6ec92ed" +dependencies = [ + "chrono", + "rust_decimal", + "sea-query-derive", + "serde_json", + "time", + "uuid 1.2.2", +] + +[[package]] +name = "sea-query-binder" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c2585b89c985cfacfe0ec9fc9e7bb055b776c1a2581c4e3c6185af2b8bf8865" +dependencies = [ + "chrono", + "rust_decimal", + "sea-query", + "serde_json", + "sqlx", + "time", + "uuid 1.2.2", +] + +[[package]] +name = "sea-query-derive" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34cdc022b4f606353fe5dc85b09713a04e433323b70163e81513b141c6ae6eb5" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", + "thiserror", +] + +[[package]] +name = "sea-schema" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38d5fda574d980e9352b6c7abd6fc75697436fe0078cac2b548559b52643ad3b" +dependencies = [ + "futures", + "sea-query", + "sea-schema-derive", +] + +[[package]] +name = "sea-schema-derive" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56821b7076f5096b8f726e2791ad255a99c82498e08ec477a65a96c461ff1927" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "sea-strum" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "391d06a6007842cfe79ac6f7f53911b76dfd69fc9a6769f1cf6569d12ce20e1b" +dependencies = [ + "sea-strum_macros", +] + +[[package]] +name = "sea-strum_macros" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69b4397b825df6ccf1e98bcdabef3bbcfc47ff5853983467850eeab878384f21" +dependencies = [ + "heck 0.3.3", + "proc-macro2", + "quote", + "rustversion", + "syn", +] + +[[package]] +name = "seahash" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c107b6f4780854c8b126e228ea8869f4d7b71260f962fefb57b996b8959ba6b" + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser", +] + +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + +[[package]] +name = "serde" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.147" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.89" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sha2" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82e6b795fe2e3b1e845bafcb27aa35405c4d47cdfc92af5fc8d3002f76cebdc0" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "sharded-slab" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900fba806f70c630b0a382d0d825e17a0f19fcd059a2ade1ff237bcddf446b31" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "shlex" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43b2853a4d09f215c24cc5489c992ce46052d359b5109343cbafbf26bc62f8a3" + +[[package]] +name = "signal-hook" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d" +dependencies = [ + "libc", + "signal-hook-registry", +] + +[[package]] +name = "signal-hook-registry" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" +dependencies = [ + "libc", +] + +[[package]] +name = "siphasher" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" + +[[package]] +name = "slab" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] + +[[package]] +name = "smallvec" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a507befe795404456341dfab10cef66ead4c041f62b8b11bbb92bffe5d0953e0" + +[[package]] +name = "socket2" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02e2d2db9033d13a1567121ddd7a095ee144db4e1ca1b1bda3419bc0da294ebd" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "spin" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" + +[[package]] +name = "spin" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6002a767bff9e83f8eeecf883ecb8011875a21ae8da43bffb817a57e78cc09" +dependencies = [ + "lock_api", +] + +[[package]] +name = "sqlformat" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f87e292b4291f154971a43c3774364e2cbcaec599d3f5bf6fa9d122885dbc38a" +dependencies = [ + "itertools", + "nom", + "unicode_categories", +] + +[[package]] +name = "sqlx" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9249290c05928352f71c077cc44a464d880c63f26f7534728cca008e135c0428" +dependencies = [ + "sqlx-core", + "sqlx-macros", +] + +[[package]] +name = "sqlx-core" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcbc16ddba161afc99e14d1713a453747a2b07fc097d2009f4c300ec99286105" +dependencies = [ + "ahash", + "atoi", + "bitflags", + "byteorder", + "bytes", + "chrono", + "crc", + "crossbeam-queue", + "dotenvy", + "either", + "event-listener", + "flume", + "futures-channel", + "futures-core", + "futures-executor", + "futures-intrusive", + "futures-util", + "hashlink", + "hex", + "indexmap", + "itoa", + "libc", + "libsqlite3-sys", + "log", + "memchr", + "num-bigint", + "once_cell", + "paste", + "percent-encoding", + "rust_decimal", + "rustls", + "rustls-pemfile", + "serde", + "serde_json", + "sha2", + "smallvec", + "sqlformat", + "sqlx-rt", + "stringprep", + "thiserror", + "time", + "url", + "uuid 1.2.2", + "webpki-roots", +] + +[[package]] +name = "sqlx-macros" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b850fa514dc11f2ee85be9d055c512aa866746adfacd1cb42d867d68e6a5b0d9" +dependencies = [ + "dotenvy", + "either", + "heck 0.4.0", + "once_cell", + "proc-macro2", + "quote", + "serde_json", + "sha2", + "sqlx-core", + "sqlx-rt", + "syn", + "url", +] + +[[package]] +name = "sqlx-rt" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24c5b2d25fa654cc5f841750b8e1cdedbe21189bf9a9382ee90bfa9dd3562396" +dependencies = [ + "async-std", + "futures-rustls", +] + +[[package]] +name = "stringprep" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ee348cb74b87454fff4b551cbf727025810a004f88aeacae7f85b87f4e9a1c1" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" + +[[package]] +name = "syn" +version = "1.0.103" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "system-deps" +version = "6.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2955b1fe31e1fa2fbd1976b71cc69a606d7d4da16f6de3333d0c92d51419aeff" +dependencies = [ + "cfg-expr", + "heck 0.4.0", + "pkg-config", + "toml", + "version-compare", +] + +[[package]] +name = "termcolor" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "textwrap" +version = "0.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" + +[[package]] +name = "thiserror" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5516c27b78311c50bf42c071425c560ac799b11c30b31f87e3081965fe5e0180" +dependencies = [ + "once_cell", +] + +[[package]] +name = "time" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a561bf4617eebd33bca6434b988f39ed798e527f51a1e797d0ee4f61c0a38376" +dependencies = [ + "itoa", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" + +[[package]] +name = "time-macros" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d967f99f534ca7e495c575c62638eebc2898a8c84c119b89e250477bc4ba16b2" +dependencies = [ + "time-core", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" + +[[package]] +name = "tokio" +version = "1.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d76ce4a75fb488c605c54bf610f221cea8b0dafb53333c1a67e8ee199dcd2ae3" +dependencies = [ + "autocfg", + "num_cpus", + "pin-project-lite", + "tokio-macros", +] + +[[package]] +name = "tokio-macros" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9724f9a975fb987ef7a3cd9be0350edcbe130698af5b8f7a631e23d42d052484" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "toml" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.14.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5376256e44f2443f8896ac012507c19a012df0fe8758b55246ae51a2279db51f" +dependencies = [ + "combine", + "indexmap", + "itertools", + "serde", +] + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "log", + "pin-project-lite", + "tracing-attributes", + "tracing-core", +] + +[[package]] +name = "tracing-attributes" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-log" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ddad33d2d10b1ed7eb9d1f518a5674713876e97e5bb9b7345a7984fbb4f922" +dependencies = [ + "lazy_static", + "log", + "tracing-core", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6176eae26dd70d0c919749377897b54a9276bd7061339665dd68777926b5a70" +dependencies = [ + "matchers", + "nu-ansi-term", + "once_cell", + "regex", + "sharded-slab", + "smallvec", + "thread_local", + "tracing", + "tracing-core", + "tracing-log", +] + +[[package]] +name = "typenum" +version = "1.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" + +[[package]] +name = "ucd-trie" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81" + +[[package]] +name = "unicode-bidi" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a" + +[[package]] +name = "unicode-width" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b" + +[[package]] +name = "unicode_categories" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" + +[[package]] +name = "untrusted" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "uuid" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" +dependencies = [ + "getrandom", +] + +[[package]] +name = "uuid" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "422ee0de9031b5b948b97a8fc04e3aa35230001a722ddd27943e0be31564ce4c" +dependencies = [ + "getrandom", + "serde", +] + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" + +[[package]] +name = "value-bag" +version = "1.0.0-alpha.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2209b78d1249f7e6f3293657c9779fe31ced465df091bbd433a1cf88e916ec55" +dependencies = [ + "ctor", + "version_check", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version-compare" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "waker-fn" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaf9f5aceeec8be17c128b2e93e031fb8a4d469bb9c4ae2d7dc1888b26887268" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c8ffb332579b0557b52d268b91feab8df3615f265d5270fec2a8c95b17c1142" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23639446165ca5a5de86ae1d8896b737ae80319560fbaa4c2887b7da6e7ebd7d" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052be0f94026e6cbc75cdefc9bae13fd6052cdcaf532fa6c45e7ae33a1e6c810" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07bc0c051dc5f23e307b13285f9d75df86bfdf816c5721e573dec1f9b8aa193c" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" + +[[package]] +name = "web-sys" +version = "0.3.60" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bcda906d8be16e728fd5adc5b729afad4e444e106ab28cd1c7256e54fa61510f" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f095d78192e208183081cc07bc5515ef55216397af48b873e5edcd72637fa1bd" +dependencies = [ + "ring", + "untrusted", +] + +[[package]] +name = "webpki-roots" +version = "0.22.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c71e40d7d2c34a5106301fb632274ca37242cd0c9d3e64dbece371a40a2d87" +dependencies = [ + "webpki", +] + +[[package]] +name = "wepoll-ffi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" +dependencies = [ + "cc", +] + +[[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41d2aa71f6f0cbe00ae5167d90ef3cfe66527d6f613ca78ac8024c3ccab9a19e" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0f252f5a35cac83d6311b2e795981f5ee6e67eb1f9a7f64eb4500fbc4dcdb4" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbeae19f6716841636c28d695375df17562ca208b2b7d0dc47635a50ae6c5de7" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84c12f65daa39dd2babe6e442988fc329d6243fdce47d7d2d155b8d874862246" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf7b1b21b5362cbc318f686150e5bcea75ecedc74dd157d874d754a2ca44b0ed" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09d525d2ba30eeb3297665bd434a54297e4170c7f1a44cad4ef58095b4cd2028" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40009d85759725a34da6d89a94e63d7bdc50a862acf0dbc7c8e488f1edcb6f5" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..2e44970 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,32 @@ +[package] +name = "celeste" +version = "0.1.0" +edition = "2021" + +[dependencies] +adw = { package = "libadwaita", version = "0.2.1", features = ["v1_2"] } +base64 = "0.20.0" +blocking = "1.3.0" +clap = { version = "4.0.12", features = ["derive", "env"] } +dirs = "4.0.0" +exitcode = "1.1.2" +file-lock = "2.1.6" +glob = "0.3.0" +hw-msg = "0.3.1" +indexmap = "1.9.2" +futures = "0.3.25" +librclone = { version = "0.3.0" } +quit = "1.1.4" +rand = "0.8.5" +regex = "1.6.0" +sea-orm = { version = "0.10.3", features = ["sqlx-sqlite", "runtime-async-std-rustls", "macros"] } +sea-orm-migration = "0.10.0" +serde = { version = "1.0.143", features = ["derive"] } +serde_json = "1.0.83" +time = { version = "0.3.17", features = ["serde-well-known"] } +tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread", "sync"] } +toml_edit = { version = "0.14.4", features = ["serde"] } +url = "2.3.1" + +[build-dependencies] +grass = "0.11.2" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f288702 --- /dev/null +++ b/LICENSE @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/PRIVACY.md b/PRIVACY.md new file mode 100644 index 0000000..9a7cdf0 --- /dev/null +++ b/PRIVACY.md @@ -0,0 +1,4 @@ +# Privacy Policy +This file is being provided in order to make the Google Drive server type function correctly. + +As would be expected, Celeste collects **no data** from the user. diff --git a/README.md b/README.md new file mode 100644 index 0000000..35cb7e7 --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# Celeste +Celeste is a GUI file synchronization client that can connect to virtually any cloud provider. + +- Backed by [rclone](https://rclone.org/), giving you a reliable and battle-tested way to sync your files anywhere +- Written with GTK4 and Libadwaita, giving Celeste a native look and feel on your desktop +- Written in Rust, making Celeste ***blazingly fast*** to use + +> **NOTE:** +> Celeste is currently alpha software, and you should likewise ensure you have a backup of your data before you decide on trying it. *Any file loss incurred is at your own risk*. + +## Features +- Two-way sync +- Ability to exclude files/folders from sync +- Connecting to multiple cloud providers at the same time + +## Supported cloud providers +Celeste can currently connect to the following cloud providers: +- Dropbox +- Nextcloud +- WebDAV + +## Installation +Celeste can be installed via the methods listed below: + +### AppImage +AppImages are published on every release on the [Releases page](https://github.com/hwittenborn/celeste/releases/latest). Note that if you use this installation method you won't receive automatic updates - if you'd prefer to have such use on of the below methods. + +### MPR Source Package (Debian/Ubuntu) +If you're on Ubuntu 22.10 or later, you can install Celeste from source on the [MPR](https://mpr.makedeb.org/packages/celeste). You'll need to have [makedeb](https://docs.makedeb.org/installing/apt-repository/) and [Mist](https://docs.makedeb.org/using-the-mpr/mist-the-mpr-cli/) installed before you do so. + +```sh +mist install celeste +``` \ No newline at end of file diff --git a/appimage/AppImageBuilder.yml b/appimage/AppImageBuilder.yml new file mode 100644 index 0000000..7b12755 --- /dev/null +++ b/appimage/AppImageBuilder.yml @@ -0,0 +1,34 @@ +version: 1 +script: + - rm -rf AppDir/ + - mkdir AppDir/ + - cargo build --release + - install -Dm 755 target/release/celeste AppDir/usr/bin/celeste + - install -Dm 644 assets/com.hunterwittenborn.Celeste.desktop AppDir/usr/share/applications/com.hunterwittenborn.Celeste.desktop + - install -Dm 644 assets/com.hunterwittenborn.Celeste-regular.svg AppDir/usr/share/icons/hicolor/64x64/apps/com.hunterwittenborn.Celeste.svg + - install -Dm 755 appimage/wrapper.sh AppDir/usr/bin/celeste-wrapper +AppDir: + path: ./AppDir + app_info: + id: com.hunterwittenborn.Celeste + name: Celeste + icon: com.hunterwittenborn.Celeste + version: 0.1.0 + exec: bin/bash + exec_args: '-c "${APPDIR}/usr/bin/celeste-wrapper ${@}"' + apt: + arch: amd64 + sources: + - sourceline: 'deb http://us.archive.ubuntu.com/ubuntu/ kinetic main universe' + key_url: 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0xf6ecb3762474eda9d21b7022871920d1991bc93c' + include: + - bash + - libadwaita-1-0 + - rclone + after_bundle: | + chmod -x AppDir/usr/bin/{celeste,rclone} # See https://github.com/AppImageCrafters/appimage-builder/issues/284. +AppImage: + update-information: None + sign-key: None + arch: x86_64 + file_name: celeste.AppImage \ No newline at end of file diff --git a/appimage/wrapper.sh b/appimage/wrapper.sh new file mode 100755 index 0000000..81a6c6e --- /dev/null +++ b/appimage/wrapper.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -e + +# We have to extract the AppImage to make modifications to the files it contains, so do that below, and clean up our work when we're done. +tmpdir="$(mktemp -d)" +cp "${APPDIR}"/* "${tmpdir}" -r +cd "${tmpdir}" + +chmod +x usr/bin/{celeste,rclone} +usr/bin/celeste "${@}" || true + +rm "${tmpdir}" -r \ No newline at end of file diff --git a/assets/com.hunterwittenborn.Celeste-nightly.svg b/assets/com.hunterwittenborn.Celeste-nightly.svg new file mode 100644 index 0000000..4d8e282 --- /dev/null +++ b/assets/com.hunterwittenborn.Celeste-nightly.svg @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/com.hunterwittenborn.Celeste-regular.svg b/assets/com.hunterwittenborn.Celeste-regular.svg new file mode 100644 index 0000000..48cfb91 --- /dev/null +++ b/assets/com.hunterwittenborn.Celeste-regular.svg @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/com.hunterwittenborn.Celeste.Source.svg b/assets/com.hunterwittenborn.Celeste.Source.svg new file mode 100644 index 0000000..20faca7 --- /dev/null +++ b/assets/com.hunterwittenborn.Celeste.Source.svg @@ -0,0 +1,3434 @@ + + + + + Adwaita Icon Template + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + GNOME Design Team + + + + + Adwaita Icon Template + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/com.hunterwittenborn.Celeste.desktop b/assets/com.hunterwittenborn.Celeste.desktop new file mode 100644 index 0000000..38a6b60 --- /dev/null +++ b/assets/com.hunterwittenborn.Celeste.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=Celeste +Exec=celeste +GenericName=Folder Sync +Comment=GUI file synchronization client that can connect to virtually any cloud provider +Keywords=cloud;file sync;backup; +Icon=com.hunterwittenborn.Celeste +Type=Application +Categories=FileTools;FileTransfer;GTK;Utility; +StartupNotify=true +Terminal=false \ No newline at end of file diff --git a/assets/style.scss b/assets/style.scss new file mode 100644 index 0000000..a39a421 --- /dev/null +++ b/assets/style.scss @@ -0,0 +1,24 @@ +// Global padding on windows. +window > *:not(contents), window > contents { + & > box, & > leaflet > box { + & > *:not(headerbar):not(stacksidebar) { + margin-left: 1em; + margin-right: 1em; + + &:nth-child(2) { + margin-top: 1em; + } + + &:last-child { + margin-bottom: 1em; + } + } + } +} + +// Formatting for code blocks. +.scrollable-codeblock { + border-style: solid; + border-width: 1px; + border-color: unquote("@borders"); +} \ No newline at end of file diff --git a/build.rs b/build.rs new file mode 100644 index 0000000..3e44e9b --- /dev/null +++ b/build.rs @@ -0,0 +1,11 @@ +use std::{fs, path::Path}; +static OUTPUT_FILE_NAME: &str = "style.css"; + +fn main() { + let scss = grass::from_path("assets/style.scss", &grass::Options::default()).unwrap(); + + if Path::new(OUTPUT_FILE_NAME).exists() { + fs::remove_file(OUTPUT_FILE_NAME).unwrap(); + } + fs::write(OUTPUT_FILE_NAME, scss).unwrap(); +} diff --git a/justfile b/justfile new file mode 100644 index 0000000..d9bc856 --- /dev/null +++ b/justfile @@ -0,0 +1,17 @@ +create-appimage: + #!/usr/bin/env bash + set -euo pipefail + cd "$(git rev-parse --show-toplevel)" + appimage-builder --recipe appimage/AppImageBuilder.yml + +get-version: + #!/usr/bin/env bash + set -euo pipefail + cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version' + +update-versions: + #!/usr/bin/env bash + set -euo pipefail + version="$(just get-version)" + sed -i "s| version: .*| version: ${version}|" appimage/AppImageBuilder.yml + sed -i "s|pkgver=.*|pkgver=${version}|" makedeb/PKGBUILD \ No newline at end of file diff --git a/makedeb/PKGBUILD b/makedeb/PKGBUILD new file mode 100644 index 0000000..eb98b72 --- /dev/null +++ b/makedeb/PKGBUILD @@ -0,0 +1,42 @@ +# Maintainer: Hunter Wittenborn +pkgname=celeste +pkgver=0.1.0 +pkgrel=1 +pkgdesc='GUI file synchronization client that can sync with any cloud provider' +arch=('any') +depends=( + 'libadwaita-1-0' + 'rclone' +) +makedepends=( + 'libadwaita-1-dev' + 'libcairo2-dev' + 'libclang-15-dev' + 'libgdk-pixbuf-2.0-dev' + 'libglib2.0-dev' + 'libgraphene-1.0-dev' + 'libgtk-4-dev' + 'libpango1.0-dev' + 'golang-go>=2:1.17' + 'pkg-config' + 'rustup' +) +license=('GPL-3.0') +url='https://github.com/hwittenborn/celeste' + +source=("${url}/archive/refs/tags/v${pkgver}.tar.gz") +sha256sums=('SKIP') + +build() { + cd "${pkgname}-${pkgver}/" + cargo build --release +} + +package() { + cd "${pkgname}-${pkgver}/" + install -Dm 755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}" + install -Dm 644 assets/com.hunterwittenborn.Celeste.desktop "${pkgdir}/usr/share/applications/com.hunterwittenborn.Celeste.desktop" + install -Dm 644 assets/com.hunterwittenborn.Celeste-regular.svg "${pkgdir}/usr/share/icons/hicolor/scalable/apps/com.hunterwittenborn.Celeste.svg" +} + +# vim: set sw=4 expandtab: \ No newline at end of file diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..271800c --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,2 @@ +[toolchain] +channel = "nightly" \ No newline at end of file diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 0000000..606e292 --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1 @@ +wrap_comments = true \ No newline at end of file diff --git a/src/about.rs b/src/about.rs new file mode 100644 index 0000000..4be737f --- /dev/null +++ b/src/about.rs @@ -0,0 +1,16 @@ +use adw::{gtk::License, prelude::*, AboutWindow, Application}; + +pub fn about_window(app: &Application) { + let window = AboutWindow::builder() + .application(app) + .application_name("Celeste") + .copyright("© 2022 Hunter Wittenborn") + .developer_name("Hunter Wittenborn") + .icon_name("com.hunterwittenborn.Celeste") + .issue_url("https://github.com/hwittenborn/celeste") + .license_type(License::Gpl30) + .support_url("https://github.com/hwittenborn/celeste/issues") + .build(); + + window.show(); +} diff --git a/src/entities/mod.rs b/src/entities/mod.rs new file mode 100644 index 0000000..b7914ae --- /dev/null +++ b/src/entities/mod.rs @@ -0,0 +1,19 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.3 +mod remotes; +mod sync_dirs; +mod sync_items; + +pub use remotes::ActiveModel as RemotesActiveModel; +pub use remotes::Column as RemotesColumn; +pub use remotes::Entity as RemotesEntity; +pub use remotes::Model as RemotesModel; + +pub use sync_dirs::ActiveModel as SyncDirsActiveModel; +pub use sync_dirs::Column as SyncDirsColumn; +pub use sync_dirs::Entity as SyncDirsEntity; +pub use sync_dirs::Model as SyncDirsModel; + +pub use sync_items::ActiveModel as SyncItemsActiveModel; +pub use sync_items::Column as SyncItemsColumn; +pub use sync_items::Entity as SyncItemsEntity; +pub use sync_items::Model as SyncItemsModel; diff --git a/src/entities/remotes.rs b/src/entities/remotes.rs new file mode 100644 index 0000000..13ebae3 --- /dev/null +++ b/src/entities/remotes.rs @@ -0,0 +1,25 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.3 +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] +#[sea_orm(table_name = "remotes")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub name: String, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm(has_many = "super::sync_dirs::Entity")] + SyncDirs, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::SyncDirs.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/entities/sync_dirs.rs b/src/entities/sync_dirs.rs new file mode 100644 index 0000000..7683fbe --- /dev/null +++ b/src/entities/sync_dirs.rs @@ -0,0 +1,61 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.3 +use crate::util; +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] +#[sea_orm(table_name = "sync_dirs")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub remote_id: i32, + /// The local directory being synced, as an absolute path with no '/' at the + /// end. + pub local_path: String, + /// The remote path being synced, as an absolute path (though it won't start + /// with `/`). + pub remote_path: String, +} + +impl Model { + // See if this item still exists in the database (i.e. the struct was created + // and the item was later deleted). + pub fn exists(&self, db: &DatabaseConnection) -> bool { + util::await_future( + Entity::find() + .filter(Column::LocalPath.eq(self.local_path.clone())) + .filter(Column::RemotePath.eq(self.remote_path.clone())) + .one(db), + ) + .unwrap() + .is_some() + } +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::remotes::Entity", + from = "Column::RemoteId", + to = "super::remotes::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + Remotes, + #[sea_orm(has_many = "super::sync_items::Entity")] + SyncItems, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::Remotes.def() + } +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::SyncItems.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/entities/sync_items.rs b/src/entities/sync_items.rs new file mode 100644 index 0000000..de5c91a --- /dev/null +++ b/src/entities/sync_items.rs @@ -0,0 +1,40 @@ +//! `SeaORM` Entity. Generated by sea-orm-codegen 0.10.3 +use sea_orm::entity::prelude::*; +use serde::{Deserialize, Serialize}; + +#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)] +#[sea_orm(table_name = "sync_items")] +pub struct Model { + #[sea_orm(primary_key)] + pub id: i32, + pub sync_dir_id: i32, + /// The local item being synced, as an absolute path with no '/' at the end. + pub local_path: String, + /// The remote path being synced, relative to the directory of the matching + /// `SyncDirs::sync_dir` specified by `Self::sync_dir_id`. + pub remote_path: String, + /// The local UNIX timestamp of the item when last synced. + pub last_local_timestamp: i32, + /// The remote UNIX timestamp of the item when last synced. + pub last_remote_timestamp: i32, +} + +#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] +pub enum Relation { + #[sea_orm( + belongs_to = "super::sync_dirs::Entity", + from = "Column::SyncDirId", + to = "super::sync_dirs::Column::Id", + on_update = "NoAction", + on_delete = "NoAction" + )] + SyncDirs, +} + +impl Related for Entity { + fn to() -> RelationDef { + Relation::SyncDirs.def() + } +} + +impl ActiveModelBehavior for ActiveModel {} diff --git a/src/gtk_util.rs b/src/gtk_util.rs new file mode 100644 index 0000000..e6d3a11 --- /dev/null +++ b/src/gtk_util.rs @@ -0,0 +1,85 @@ +use crate::{mpsc, util}; +use adw::{ + glib, + gtk::{Orientation, ScrolledWindow, Separator, TextBuffer, TextView}, + prelude::*, + MessageDialog, +}; + +/// Show an error screen. +pub fn show_error(title: &str, primary_text: &str, secondary_text: Option<&str>) { + let (sender, mut reciever) = mpsc::channel::<()>(); + let mut dialog = MessageDialog::builder() + .title(&util::get_title!("{}", title)) + .heading(primary_text) + .modal(true) + .resizable(true); + if let Some(text) = secondary_text { + dialog = dialog.body(text); + } + let dialog = dialog.build(); + dialog.add_response("ok", "Ok"); + dialog.connect_response( + None, + glib::clone!(@strong sender => move |dialog, resp| { + if ["ok"].contains(&resp) { + dialog.close(); + sender.send(()); + } + }), + ); + dialog.show(); + reciever.recv(); +} + +// Show an error screen with a codeblock. +pub fn show_codeblock_error(title: &str, primary_text: &str, code: &str) { + let (sender, mut reciever) = mpsc::channel::<()>(); + let dialog = MessageDialog::builder() + .title(&util::get_title!("{title}")) + .heading(primary_text) + .extra_child(&codeblock(code)) + .resizable(true) + .build(); + dialog.add_response("ok", "Ok"); + dialog.connect_response( + None, + glib::clone!(@strong sender => move |dialog, resp| { + if resp != "ok" { + return; + } + dialog.close(); + sender.send(()); + }), + ); + dialog.show(); + reciever.recv(); +} + +/// Create a codeblock. +pub fn codeblock(text: &str) -> ScrolledWindow { + let buffer = TextBuffer::builder().text(text).build(); + let block = TextView::builder() + .buffer(&buffer) + .editable(false) + .focusable(false) + .monospace(true) + .build(); + ScrolledWindow::builder() + .child(&block) + .hexpand(true) + .vexpand(true) + .min_content_width(100) + .min_content_height(100) + .margin_top(10) + .css_classes(vec!["scrollable-codeblock".to_string()]) + .build() +} + +/// Get an invisible separator. +pub fn separator() -> Separator { + Separator::builder() + .orientation(Orientation::Vertical) + .css_classes(vec!["spacer".to_string()]) + .build() +} diff --git a/src/launch.rs b/src/launch.rs new file mode 100644 index 0000000..56fc0c3 --- /dev/null +++ b/src/launch.rs @@ -0,0 +1,2197 @@ +use crate::{ + entities::{ + RemotesColumn, RemotesEntity, RemotesModel, SyncDirsActiveModel, SyncDirsColumn, + SyncDirsEntity, SyncDirsModel, SyncItemsActiveModel, SyncItemsColumn, SyncItemsEntity, + }, + gtk_util, + login::{self}, + migrations::{Migrator, MigratorTrait}, + rclone::{self, RcloneError, RcloneListFilter}, + traits::prelude::*, + util, +}; +use adw::{ + glib, + gtk::{ + pango::EllipsizeMode, Align, Box, Button, ButtonsType, Entry, EntryCompletion, + FileChooserDialog, FileFilter, GestureClick, Image, Inhibit, Label, ListBox, ListBoxRow, + ListStore, MessageDialog, Orientation, Popover, PositionType, ResponseType, SelectionMode, + Separator, Spinner, Stack, StackSidebar, StackTransitionType, Widget, + }, + prelude::*, + Application, ApplicationWindow, Bin, EntryRow, HeaderBar, Leaflet, LeafletTransitionType, +}; +use file_lock::{FileLock, FileOptions}; +use indexmap::IndexMap; +use sea_orm::{entity::prelude::*, ActiveValue, Database, DatabaseConnection}; + +use std::{ + cell::RefCell, + collections::HashMap, + fs::{self, OpenOptions}, + io::Write, + path::Path, + rc::Rc, + thread, + time::{Duration, SystemTime}, +}; + +// The location for file ignore lists. +static FILE_IGNORE_NAME: &str = ".sync-exclude.lst"; + +// A [`HashMap`] containing the status and progress for a directory sync label. +// This is done here because if we try to get the child from a `Box` or +// something we just get a generic gtk `Widget`, which we can't use. +type DirectoryMap = Rc>>>; + +// A [`Vec`] for a deletion queue to remove remotes. +type RemoteDeletionQueue = Rc>>; + +// A [`Vec`] for a deletion queue to stop syncing directories - we store this in +// a queue so we can stop syncing directories safely while syncs may still be +// occuring. +type SyncDirDeletionQueue = Rc>>; + +/// The errors that can be found while syncing. +#[derive(Clone, Debug, PartialEq, Eq, Hash)] +enum SyncError { + /// A general catch-all error. A tuple of the path the error happened at, + /// and the error message itself. + General(String, String), + /// An error when both the local and remote file are more current than at + /// the last sync. A tuple of the local and remote file. + BothMoreCurrent(String, String), +} + +impl SyncError { + fn generate_ui(&self) -> Box { + let error_container = Box::builder() + .orientation(Orientation::Vertical) + .spacing(2) + .margin_top(6) + .margin_end(6) + .margin_bottom(6) + .margin_start(6) + .build(); + + match self { + SyncError::General(file_path, err) => { + let err_label = Label::builder() + .label(file_path) + .halign(Align::Start) + .ellipsize(EllipsizeMode::End) + .build(); + let file_label = Label::builder() + .label(err) + .halign(Align::Start) + .ellipsize(EllipsizeMode::End) + .css_classes(vec!["caption".to_string(), "dim-label".to_string()]) + .build(); + error_container.append(&err_label); + error_container.append(&file_label); + } + SyncError::BothMoreCurrent(local_path, remote_path) => { + let err_msg = format!( + "Both '{local_path}' and '{remote_path}' are more recent than at last sync." + ); + let err_label = Label::builder() + .label(&err_msg) + .halign(Align::Start) + .ellipsize(EllipsizeMode::End) + .build(); + error_container.append(&err_label); + } + } + + error_container + } +} +/// A struct representing all the data that belongs to a sync directory. +struct SyncDir { + /// The parent stack for [`Self::container`], this contains all the UI + /// listing for sync directories. + parent_list: ListBox, + /// The Box containing things like the progress icon, status text, etc. + container: ListBoxRow, + /// The container for the progress icon. + status_icon: Bin, + /// The label for reporting errors in the current sync status. + error_status_text: Label, + /// The label for reporting the current sync status (things like 'Awaiting + /// sync check...'). + status_text: Label, + /// The error list in the UI. + error_list: ListBox, + /// The list of error items, as generated by 'SyncError::generate_ui' above. + error_items: HashMap, +} + +/// Get an icon for use as the status icon for directory syncs. +fn get_image(icon_name: &str) -> Image { + Image::builder() + .icon_name(icon_name) + .width_request(10) + .height_request(10) + .build() +} + +pub fn launch(app: &Application) { + // Create the lock file. + fs::File::create(&util::is_running_file()).unwrap(); + + // Create the configuration directory if it doesn't exist. + let config_path = util::get_config_dir(); + if !config_path.exists() && let Err(err) = fs::create_dir_all(&config_path) { + gtk_util::show_error( + "Config Error", + &format!("Unable to create Celeste's config directory [{err}]."), + None + ); + return; + } + + // Create the database file if it doesn't exist. + let mut db_path = config_path; + db_path.push("celeste.db"); + if !db_path.exists() { + if let Err(err) = fs::File::create(&db_path) { + gtk_util::show_error( + "Database Error", + &format!("Unable to create Celeste's database file [{err}]."), + None, + ); + return; + } + }; + + // Connect to the database. + let db = util::await_future(Database::connect(format!("sqlite://{}", db_path.display()))); + if let Err(err) = &db { + gtk_util::show_error( + "Database Error", + &format!("Unable to connect to database [{err}]."), + None, + ); + return; + }; + let db = db.unwrap(); + + // Run migrations. + if let Err(err) = util::await_future(Migrator::up(&db, None)) { + gtk_util::show_error( + "Database Error", + &format!("Unable to run database migrations [{err}]"), + None, + ); + return; + } + + // Get our remotes. + let mut remotes = util::await_future(RemotesEntity::find().all(&db)).unwrap(); + + if remotes.is_empty() { + if login::login(app, &db).is_none() { + return; + } + + remotes = util::await_future(RemotesEntity::find().all(&db)).unwrap(); + } + + // Create the main UI. + let window = ApplicationWindow::builder() + .application(app) + .title(&util::get_title!("Servers")) + .build(); + let stack_sidebar = StackSidebar::builder() + .width_request(150) + .height_request(500) + .vexpand_set(true) + .vexpand(true) + .build(); + let stack = Stack::new(); + stack_sidebar.set_stack(&stack); + + let directory_map: DirectoryMap = Rc::new(RefCell::new(IndexMap::new())); + + // Store any remote deletions (values of the remote names) in a queue so they + // can be processed when syncing is at a good point of stopping. + let remote_deletion_queue: RemoteDeletionQueue = Rc::new(RefCell::new(vec![])); + + // Store any sync deletions (the remote + local directory + remote directory) in + // a queue so they can be processed when syncing is at a good point of stopping. + let sync_dir_deletion_queue: SyncDirDeletionQueue = Rc::new(RefCell::new(vec![])); + + // Add servers. + let gen_remote_window = glib::clone!(@strong window, @strong remote_deletion_queue, @strong sync_dir_deletion_queue, @strong directory_map, @strong db => move |remote: RemotesModel| { + let remote_name = remote.name; + + // The stack containing the window of sync status', as well as extra information for each sync pair. + let sections = Stack::builder() + .transition_type(StackTransitionType::OverLeft) + .transition_duration(500) + .build(); + + // The sections of this stack's window. + let page = Box::builder() + .orientation(Orientation::Vertical) + .vexpand_set(true) + .vexpand(true) + .css_classes(vec!["background".to_string()]) + .build(); + + // The list of directories to sync. + let sync_dirs = ListBox::builder() + .selection_mode(SelectionMode::None) + .css_classes(vec!["boxed-list".to_string()]) + .build(); + + // Add a directory to the stack. + let add_dir = glib::clone!(@weak window, @weak sections, @weak page, @weak sync_dirs, @strong remote_name, @strong directory_map, @strong sync_dir_deletion_queue => move | + server_name: String, + local_path: String, + remote_path: String, + | { + let server_name_owned = server_name.to_string(); + let formatted_local_path = util::fmt_home(&local_path); + let formatted_remote_path = format!("/{remote_path}"); + + // The sync status row. + let sync_status_sections = Box::builder().orientation(Orientation::Vertical).margin_start(10).margin_end(10).build(); + let row_sections = Box::builder().orientation(Orientation::Horizontal).build(); + let status_container = Bin::builder().width_request(30).build(); + status_container.set_child(Some(&get_image("content-loading-symbolic"))); + row_sections.append(&status_container); + + let text_sections = Box::builder().orientation(Orientation::Vertical).valign(Align::Center).margin_start(10).margin_end(10).margin_top(5).margin_bottom(5).build(); + let title = { + let sections = Box::builder().orientation(Orientation::Horizontal).build(); + let local_label = Label::builder().label(&formatted_local_path).ellipsize(EllipsizeMode::Start).build(); + let remote_label = Label::builder().label(&formatted_remote_path).ellipsize(EllipsizeMode::Start).build(); + let arrow = Image::builder().icon_name("go-next-symbolic").build(); + sections.append(&local_label); + sections.append(&arrow); + sections.append(&remote_label); + sections + }; + let text_status_container = Box::builder().orientation(Orientation::Horizontal).build(); + let error_status = Label::builder() + .halign(Align::Start) + .css_classes(vec!["caption".to_string(), "dim-label".to_string(), "error".to_string()]) + .build(); + let status = Label::builder() + .label("Awaiting sync check...") + .halign(Align::Start) + .css_classes(vec!["caption".to_string(), "dim-label".to_string()]) + .ellipsize(EllipsizeMode::End) + .build(); + text_status_container.append(&error_status); + text_status_container.append(&status); + text_sections.append(&title); + text_sections.append(&text_status_container); + + row_sections.append(&text_sections); + + let more_info_button = Image::builder() + .icon_name("go-next-symbolic") + .halign(Align::End) + .hexpand_set(true) + .hexpand(true) + .build(); + + row_sections.append(&more_info_button); + sync_status_sections.append(&row_sections); + + // The more info page. + let more_info_page = Box::builder() + .orientation(Orientation::Vertical) + .vexpand_set(true) + .vexpand(true) + .css_classes(vec!["background".to_string()]) + .build(); + let more_info_header_buttons = Box::builder() + .orientation(Orientation::Horizontal) + .margin_bottom(10) + .build(); + + // The errors section. + let more_info_errors_label = Label::builder() + .label("Sync Errors") + .halign(Align::Start) + .hexpand_set(true) + .hexpand(true) + .valign(Align::End) + .margin_bottom(10) + .css_classes(vec!["heading".to_string()]) + .build(); + let more_info_errors_list = ListBox::builder().selection_mode(SelectionMode::None).css_classes(vec!["boxed-list".to_string()]).build(); + + // The exclusion list. + let more_info_exclusions_header = Box::builder().orientation(Orientation::Horizontal).margin_top(20).margin_bottom(10).build(); + let more_info_exclusions_label = Label::builder() + .label("File/Folder Exclusions") + .halign(Align::Start) + .hexpand_set(true) + .hexpand(true) + .valign(Align::End) + .css_classes(vec!["heading".to_string()]) + .build(); + let more_info_exclusions_add_button = Button::builder() + .icon_name("list-add-symbolic") + .halign(Align::End) + .build(); + more_info_exclusions_header.append(&more_info_exclusions_label); + more_info_exclusions_header.append(&more_info_exclusions_add_button); + let more_info_exclusions_list = ListBox::builder().selection_mode(SelectionMode::None).css_classes(vec!["boxed-list".to_string()]).build(); + + // Read the ignore file to see if anything exists in it so far. + let file_ignore_path_string = format!("{local_path}/{FILE_IGNORE_NAME}"); + let get_lock = glib::clone!(@strong file_ignore_path_string => move || { + FileLock::lock(&file_ignore_path_string, true, FileOptions::new().create(true).read(true).write(true).append(false)).unwrap() + }); + + let lock = get_lock(); + let file_ignore_content = fs::read_to_string(&file_ignore_path_string).unwrap(); + lock.unlock().unwrap(); + + let ignore_rules: Rc>> = Rc::new(RefCell::new(IndexMap::new())); + let write_file = glib::clone!(@strong file_ignore_path_string, @strong ignore_rules, @strong get_lock => move || { + let ptr = ignore_rules.get_ref(); + let strings: Vec = ptr.values().map(|item| item.to_owned()).collect(); + + // First truncate the file. + OpenOptions::new().write(true).truncate(true).open(&file_ignore_path_string).unwrap(); + + // And then write to it. + get_lock().file.write_all(strings.join("\n").as_bytes()).unwrap(); + }); + let gen_ignore_row = glib::clone!(@strong get_lock, @strong write_file, @strong ignore_rules, @strong more_info_exclusions_list => move |content: Option| { + let row = EntryRow::builder().css_classes(vec!["no-title".to_string()]).build(); + if let Some(text) = content { + row.set_text(&text); + } else { + row.set_show_apply_button(true); + } + let remove_button = Button::builder().icon_name("list-remove-symbolic").valign(Align::Center).css_classes(vec!["flat".to_string()]).build(); + row.connect_apply(glib::clone!(@strong get_lock, @strong write_file, @strong ignore_rules => move |row| { + // Make sure our ignore rules has the latest string for this item. + let mut ptr = ignore_rules.get_mut_ref(); + ptr.insert(row.clone(), row.text().to_string()); + drop(ptr); + + // Write out all the current ignore rules to the file. + write_file(); + })); + remove_button.connect_clicked(glib::clone!(@strong get_lock, @strong write_file, @strong ignore_rules, @weak row, @weak more_info_exclusions_list => move |_| { + row.set_sensitive(false); + more_info_exclusions_list.remove(&row); + + // This returns [`None`] if the item hasn't been added via `row.connect_apply` above yet. + let mut ptr = ignore_rules.get_mut_ref(); + if ptr.remove(&row).is_none() { + return; + } + + drop(ptr); + write_file(); + })); + row.connect_changed(|row| { + let text = row.text().to_string(); + + // If this row is valid, show the apply button. Otherwise, hide it. + if let Err(err) = glob::Pattern::new(&text) { + row.set_show_apply_button(false); + row.add_css_class("error"); + row.set_tooltip_text(Some(&err.to_string())); + } else { + row.remove_css_class("error"); + row.set_tooltip_text(None); + row.set_show_apply_button(true); + } + }); + row.add_suffix(&remove_button); + row + }); + more_info_exclusions_add_button.connect_clicked(glib::clone!(@weak more_info_exclusions_list, @strong gen_ignore_row => move |_| { + more_info_exclusions_list.append(&gen_ignore_row(None)); + })); + + for line in file_ignore_content.lines() { + let line_owned = line.to_owned(); + let row = gen_ignore_row(Some(line_owned.clone())); + more_info_exclusions_list.append(&row); + ignore_rules.get_mut_ref().insert(row, line_owned); + } + + // The back button to go back to the main page. + let more_info_back_button = Button::builder() + .icon_name("go-previous-symbolic") + .halign(Align::Start) + .hexpand_set(true) + .hexpand(true) + .build(); + more_info_back_button.connect_clicked(glib::clone!(@weak sections => move |_| { + // Temporarily reverse the transition direction so it looks like we're going back a page. + let previous_transition_type = sections.transition_type(); + sections.set_transition_type(StackTransitionType::OverRight); + sections.set_visible_child_name("main"); + sections.set_transition_type(previous_transition_type); + })); + let more_info_delete_button = Button::builder() + .icon_name("user-trash-symbolic") + .has_tooltip(true) + .tooltip_text("Stop syncing this directory") + .halign(Align::End) + .build(); + + // Store the pages element's in a vector. When the delete button is pressed and we confirm a deletion, we want the entire page to not be sensitive except for the back button, and we do that by only making the back button sensitive. + let more_info_widgets: Vec = vec![ + more_info_errors_label.clone().into(), + more_info_errors_list.clone().into(), + more_info_exclusions_header.clone().into(), + more_info_exclusions_list.clone().into(), + more_info_back_button.clone().into(), + more_info_delete_button.clone().into(), + ]; + more_info_delete_button.connect_clicked(glib::clone!(@strong sync_dir_deletion_queue, @strong server_name, @strong local_path, @strong remote_path, @strong formatted_local_path, @strong formatted_remote_path, @weak sections, @weak more_info_back_button, @weak more_info_delete_button, @strong more_info_widgets => move |_| { + more_info_widgets.iter().for_each(|item| item.set_sensitive(false)); + let dialog = MessageDialog::builder() + .title(&util::get_title!("Confirm Sync Dir Deletion")) + .text( + &format!("Are you sure you want to stop syncing {formatted_local_path} to {formatted_remote_path}?") + ) + .buttons(ButtonsType::YesNo) + .build(); + dialog.connect_response(glib::clone!(@strong sync_dir_deletion_queue, @strong server_name, @strong local_path, @strong remote_path, @weak sections, @weak more_info_back_button, @weak more_info_delete_button, @strong more_info_widgets => move |dialog, resp| { + match resp { + ResponseType::Yes => { + let data = (server_name.clone(), local_path.clone(), remote_path.clone()); + sync_dir_deletion_queue.get_mut_ref().push(data); + more_info_delete_button.set_tooltip_text(Some("This directory is currently being processed to no longer be synced.")); + more_info_back_button.set_sensitive(true); + dialog.close(); + }, + ResponseType::No => { + dialog.close(); + more_info_widgets.iter().for_each(|item| item.set_sensitive(true)); + }, + _ => () + } + + })); + dialog.show(); + })); + more_info_header_buttons.append(&more_info_back_button); + more_info_header_buttons.append(&more_info_delete_button); + more_info_page.append(&more_info_header_buttons); + more_info_page.append(&more_info_errors_label); + more_info_page.append(&more_info_errors_list); + more_info_page.append(&more_info_exclusions_header); + more_info_page.append(&more_info_exclusions_list); + + // Show the window upon click. + let stack_child_name = format!("{local_path}/{remote_path}"); + let gesture = GestureClick::new(); + gesture.connect_released(glib::clone!(@strong remote_name, @strong directory_map, @weak sections, @strong local_path, @strong remote_path, @strong stack_child_name, @weak more_info_page => move |_, _, _, _| { + sections.set_visible_child_name(&stack_child_name); + })); + sync_status_sections.add_controller(&gesture); + + // Add the items to the directory map. + let sync_status_sections_container = ListBoxRow::builder().child(&sync_status_sections).build(); + let mut dmap = directory_map.borrow_mut(); + + if !dmap.contains_key(&server_name_owned) { + dmap.insert(server_name_owned, IndexMap::new()); + } + + dmap.get_mut(&server_name).unwrap().insert( + (local_path, remote_path), + SyncDir { + parent_list: sync_dirs.clone(), + container: sync_status_sections_container.clone(), + status_icon: status_container, + error_status_text: error_status, + status_text: status, + error_list: more_info_errors_list, + error_items: HashMap::new() + } + ); + + sync_dirs.append(&sync_status_sections_container); + sections.add_named(&more_info_page, Some(&stack_child_name)); + }); + + // Create the remote in the database if it doesn't current exist. + let db_remote = util::await_future( + RemotesEntity::find() + .filter(RemotesColumn::Name.eq(remote_name.clone())) + .one(&db), + ) + .unwrap().unwrap(); + + // The directory header, directory addition button, and remote deletion button. + { + let section = Box::builder().orientation(Orientation::Horizontal).build(); + let label = Label::builder() + .label("Directories") + .halign(Align::Start) + .hexpand(true) + .hexpand_set(true) + .valign(Align::End) + .margin_end(10) + .css_classes(vec!["heading".to_string()]) + .build(); + let new_folder_button = Button::builder() + .icon_name("folder-new") + .halign(Align::End) + .valign(Align::Start) + .build(); + new_folder_button.connect_clicked(glib::clone!(@weak window, @weak sections, @weak page, @strong remote_name, @strong sync_dirs, @strong db, @strong directory_map, @strong db_remote, @strong add_dir => @default-panic, move |_| { + window.set_sensitive(false); + let folder_window = ApplicationWindow::builder() + .title(&util::get_title!("Remote Folder Picker")) + .build(); + let folder_sections = Box::builder().orientation(Orientation::Vertical).build(); + folder_sections.append(&HeaderBar::new()); + + // Get the local folder to sync with. + let local_label = Label::builder().label("Local folder:").halign(Align::Start).css_classes(vec!["heading".to_string()]).build(); + let local_entry = Entry::builder() + .secondary_icon_activatable(true) + .secondary_icon_name("folder-symbolic") + .secondary_icon_sensitive(true) + .build(); + local_entry.connect_icon_press(glib::clone!(@weak folder_window, @weak local_label => move |local_entry, _| { + folder_window.set_sensitive(false); + let filter = FileFilter::new(); + filter.add_mime_type("inode/directory"); + let dialog = FileChooserDialog::builder() + .title(&util::get_title!("Local Folder Picker")) + .select_multiple(false) + .create_folders(true) + .filter(&filter) + .build(); + let cancel_button = Button::with_label("Cancel"); + let ok_button = Button::with_label("Ok"); + dialog.add_action_widget(&cancel_button, ResponseType::Cancel); + dialog.add_action_widget(&ok_button, ResponseType::Ok); + dialog.connect_close_request(glib::clone!(@strong folder_window => move |_| { + folder_window.set_sensitive(true); + Inhibit(false) + })); + cancel_button.connect_clicked(glib::clone!(@weak folder_window, @weak dialog => move |_| { + dialog.close(); + })); + ok_button.connect_clicked(glib::clone!(@weak folder_window, @weak local_entry, @weak dialog => move |_| { + local_entry.set_text(&dialog.file().unwrap().path().unwrap().into_os_string().into_string().unwrap()); + dialog.close(); + })); + dialog.show(); + })); + + // Get the remote folder to sync with, and add it. + // The entry completion code is largely inspired by https://github.com/gtk-rs/gtk4-rs/blob/master/examples/entry_completion/main.rs. I honestly have no clue what half the code for that is doing, I just know the current code is working well enough, and it can be fixed later if it breaks. + let remote_label = Label::builder().label("Remote folder:").halign(Align::Start).css_classes(vec!["heading".to_string()]).build(); + let entry_completion = EntryCompletion::new(); + let store = ListStore::new(&[glib::Type::STRING]); + entry_completion.set_text_column(0); + entry_completion.set_popup_completion(true); + entry_completion.set_model(Some(&store)); + let remote_entry = Entry::builder().completion(&entry_completion).build(); + remote_entry.insert_text("/", &mut -1); + let get_remotes = || { + let mut err: Option = None; + let mut dirs = vec![]; + + for _ in 0..3 { + match rclone::sync::list(&remote_name, "/", true, RcloneListFilter::Dirs) { + Ok(folders) => { + err = None; + dirs = folders.iter().map(|item| item.path.clone()).collect::>(); + break; + }, + Err(rclone_err) => err = Some(rclone_err), + } + } + + if err.is_some() { + vec![] + } else { + dirs + } + }; + let remotes = Rc::new(RefCell::new(get_remotes())); + + remote_entry.connect_changed(glib::clone!(@strong remote_name, @weak store, @strong remotes => move |entry| { + store.clear(); + let borrowed_remotes = remotes.borrow(); + let mut valid_remotes = vec![]; + + // Get the currently specified directory by getting everything up to the last `/` (or nothing if none is present). + // Also remove any '/' at the beginning of a string if present, as Rclone strips them too and we'll have missing matches in our completion dropdown otherwise. + let entry_text = match entry.text().to_string().strip_prefix('/') { + Some(string) => string.to_string(), + None => entry.text().to_string() + }; + let directory = match entry_text.rsplit_once('/') { + Some((string, _)) => string.to_string() + "/", + None => String::new() + }; + + // Get the list of remotes we want to present to the user. + for remote in &*borrowed_remotes { + if remote.starts_with(&directory) { + let remote_stripped = if !directory.is_empty() { + remote.strip_prefix(&directory).unwrap().to_string() + } else { + remote.to_string() + }; + + match remote_stripped.split_once('/') { + Some((string, _)) => valid_remotes.push(string.to_string()), + None => valid_remotes.push(remote_stripped.to_string()) + } + } + } + + valid_remotes.sort_unstable(); + valid_remotes.dedup(); + + for remote in valid_remotes { + store.set(&store.append(), &[(0, &remote)]); + } + })); + entry_completion.set_match_func(glib::clone!(@strong remote_entry => move |completion, _entry_str, tree_iter| { + let tree_model = completion.model().unwrap(); + let text_column = completion.text_column(); + let text_value = match tree_model.get_value(tree_iter, text_column).get::() { + // Not quite sure when this could be failing, but it does sometimes so just return early if that's the case. + Ok(value) => value, + Err(_) => return false, + }; + + // The last component of the directory specified by the user. + let entry_text = remote_entry.text().to_string(); + let directory = match entry_text.rsplit_once('/') { + Some((_, string)) => string.to_string(), + None => entry_text + }; + + text_value.starts_with(&directory) + })); + entry_completion.connect_match_selected(glib::clone!(@strong remote_entry => move |_, model, iter| { + let new_text = model.get::(iter, 0); + let current_text = remote_entry.text().to_string(); + let current_text_up_to_slash = match current_text.rsplit_once('/') { + Some((string, _)) => string.to_string(), + None => String::new() + }; + + remote_entry.delete_text(current_text_up_to_slash.len() as i32, -1); + if current_text_up_to_slash.is_empty() { + // If we're at the first directory component (i.e. `/Doc` and filling in `Documents/`), we need to check if the user entered a `/` at the beginning so we can preserve it. + if current_text.starts_with('/') { + remote_entry.insert_text("/", &mut -1); + } + + remote_entry.insert_text(&format!("{new_text}/"), &mut -1); + } else { + remote_entry.insert_text(&format!("/{new_text}/"), &mut -1); + } + + remote_entry.grab_focus().then_some(()).unwrap(); + remote_entry.set_position(-1); + Inhibit(true) + })); + folder_sections.append(&local_label); + folder_sections.append(&local_entry); + folder_sections.append(&Separator::builder().orientation(Orientation::Vertical).css_classes(vec!["spacer".to_string()]).build()); + folder_sections.append(&remote_label); + folder_sections.append(&remote_entry); + let confirm_box = Box::builder().orientation(Orientation::Horizontal).spacing(10).halign(Align::End).build(); + let cancel_button = Button::with_label("Cancel"); + let ok_button = Button::with_label("Ok"); + confirm_box.append(&cancel_button); + confirm_box.append(&ok_button); + folder_sections.append(&Separator::builder().orientation(Orientation::Vertical).css_classes(vec!["spacer".to_string()]).build()); + folder_sections.append(&confirm_box); + + // If either entry is empty, don't allow the button to be clicked. + // Also initialize the button as non-clickable. + ok_button.set_sensitive(false); + + local_entry.connect_changed(glib::clone!(@weak ok_button, @weak remote_entry => move |local_entry| { + if local_entry.to_string().is_empty() || remote_entry.to_string().is_empty() { + ok_button.set_sensitive(false); + } else { + ok_button.set_sensitive(true); + } + })); + remote_entry.connect_changed(glib::clone!(@weak ok_button, @weak local_entry => move |remote_entry| { + if local_entry.to_string().is_empty() || remote_entry.to_string().is_empty() { + ok_button.set_sensitive(false); + } else { + ok_button.set_sensitive(true); + } + })); + + folder_window.connect_close_request(glib::clone!(@strong window => move |_| { + window.set_sensitive(true); + Inhibit(false) + })); + cancel_button.connect_clicked(glib::clone!(@strong window, @weak folder_window => move |_| { + folder_window.close(); + window.set_sensitive(true); + })); + ok_button.connect_clicked(glib::clone!(@strong window, @weak sections, @weak folder_window, @weak sync_dirs, @weak local_entry, @weak remote_entry, @strong db_remote, @strong db, @weak directory_map, @strong remote_name, @strong add_dir => move |_| { + folder_window.set_sensitive(false); + + let local_text = local_entry.text().to_string(); + let remote_text = util::strip_slashes(remote_entry.text().as_str()); + let local_path = Path::new(&local_text); + match rclone::sync::stat(&remote_name, &remote_text) { + Ok(path) => { + if path.is_none() { + gtk_util::show_error("Validation Error", "The specified remote directory doesn't exist", None); + folder_window.set_sensitive(true); + return; + } else { + path + } + }, + Err(err) => { + gtk_util::show_error("Validation Error", "Failed to check if the specified remote directory exists", Some(&err.error)); + folder_window.set_sensitive(true); + return; + } + }; + + let sync_dir = util::await_future( + SyncDirsEntity::find().filter(SyncDirsColumn::LocalPath.eq(local_text.clone())).filter(SyncDirsColumn::RemotePath.eq(remote_text.clone())).one(&db) + ).unwrap(); + + if sync_dir.is_some() { + gtk_util::show_error("Validation Error", "The specified directory pair is already being synced", None); + folder_window.set_sensitive(true); + } else if !local_path.exists() { + gtk_util::show_error("Validation Error", "The specified local directory doesn't exist", None); + folder_window.set_sensitive(true); + } else if !local_path.is_dir() { + gtk_util::show_error("Validation Error", "The specified local path isn't a directory", None); + folder_window.set_sensitive(true); + } else if !local_path.is_absolute() { + gtk_util::show_error("Validation Error", "The specified local directory needs to be an absolute path", None); + folder_window.set_sensitive(true); + } else { + util::await_future( + SyncDirsActiveModel { + remote_id: ActiveValue::Set(db_remote.id), + local_path: ActiveValue::Set(local_text.clone()), + remote_path: ActiveValue::Set(remote_text.clone()), + ..Default::default() + }.insert(&db) + ).unwrap(); + add_dir(remote_name.clone(), local_text, remote_text); + folder_window.close(); + } + })); + + folder_window.set_content(Some(&folder_sections)); + folder_window.show(); + })); + let delete_remote_button = Button::builder() + .icon_name("user-trash-symbolic") + .halign(Align::End) + .valign(Align::Start) + .margin_start(10) + .build(); + delete_remote_button.connect_clicked(glib::clone!(@strong remote_deletion_queue, @strong page, @strong remote_name => move |delete_remote_button| { + page.set_sensitive(false); + let dialog = MessageDialog::builder() + .title(&util::get_title!("Confirm Remote Deletion")) + .text("Are you sure you want to delete this remote?") + .secondary_text("All the directories associated with this remote will also stop syncing.") + .buttons(ButtonsType::YesNo) + .build(); + dialog.connect_response(glib::clone!(@strong remote_deletion_queue, @strong page, @strong remote_name, @weak delete_remote_button => move |dialog, resp| { + match resp { + ResponseType::Yes => { + remote_deletion_queue.get_mut_ref().push(remote_name.clone()); + dialog.close(); + }, + ResponseType::No => { + dialog.close(); + page.set_sensitive(true); + } + _ => () + } + })); + dialog.show(); + })); + section.append(&label); + section.append(&new_folder_button); + section.append(&delete_remote_button); + page.append(§ion); + } + + // The directory listing. + { + // Get the currently present directories. + let dirs = util::await_future( + SyncDirsEntity::find() + .filter(SyncDirsColumn::RemoteId.eq(db_remote.id)) + .all(&db), + ) + .unwrap(); + // Create the entry for each directory. + for dir in dirs { + add_dir( + db_remote.name.clone(), + dir.local_path.clone(), + dir.remote_path.clone(), + ); + } + } + page.append(>k_util::separator()); + page.append(&sync_dirs); + + sections.add_named(&page, Some("main")); + sections.set_visible_child_name("main"); + sections + }); + + for remote in remotes { + let window = gen_remote_window(remote.clone()); + stack.add_titled(&window, Some(&remote.name), &remote.name); + } + + // The request to close the window. + let quit_request = Rc::new(RefCell::new(false)); + + // Set up the main sections. + let sections = Leaflet::builder() + .transition_type(LeafletTransitionType::Slide) + .css_classes(vec!["main".to_string()]) + .build(); + + let sidebar_box = Box::builder() + .orientation(Orientation::Vertical) + .css_classes(vec!["sidebar".to_string()]) + .build(); + let sidebar_header = HeaderBar::builder().decoration_layout("").build(); + let sidebar_add_server_button = Button::from_icon_name("list-add-symbolic"); + sidebar_add_server_button.connect_clicked( + glib::clone!(@weak app, @weak window, @weak stack, @strong gen_remote_window, @strong db => move |_| { + window.set_sensitive(false); + + if let Some(remote) = login::login(&app, &db) { + let window = gen_remote_window(remote.clone()); + stack.add_titled(&window, None, &remote.name); + } + + window.set_sensitive(true); + }), + ); + let sidebar_menu_button = Button::from_icon_name("open-menu-symbolic"); + let sidebar_menu_popover_sections = Box::new(Orientation::Vertical, 5); + let sidebar_menu_popover = Popover::builder() + .child(&sidebar_menu_popover_sections) + .position(PositionType::Bottom) + .build(); + let sidebar_menu_about_button = Button::builder() + .label("About") + .css_classes(vec!["flat".to_string()]) + .build(); + sidebar_menu_about_button.connect_clicked( + glib::clone!(@weak app, @weak sidebar_menu_popover => move |_| { + sidebar_menu_popover.popdown(); + crate::about::about_window(&app); + }), + ); + let sidebar_menu_quit_button = Button::builder() + .label("Quit") + .css_classes(vec!["flat".to_string()]) + .build(); + sidebar_menu_quit_button.connect_clicked( + glib::clone!(@weak sidebar_menu_popover, @strong quit_request => move |_| { + sidebar_menu_popover.popdown(); + *quit_request.get_mut_ref() = true; + }), + ); + sidebar_menu_popover_sections.append(&sidebar_menu_about_button); + sidebar_menu_popover_sections.append(&sidebar_menu_quit_button); + sidebar_menu_popover.set_parent(&sidebar_menu_button); + sidebar_menu_button.connect_clicked(glib::clone!(@weak sidebar_menu_popover => move |_| { + sidebar_menu_popover.popup(); + })); + let sidebar_nav_right_button = Button::from_icon_name("go-next-symbolic"); + sidebar_header.pack_start(&sidebar_add_server_button); + sidebar_box.append(&sidebar_header); + sidebar_box.append(&stack_sidebar); + + let stack_box = Box::builder() + .orientation(Orientation::Vertical) + .hexpand_set(true) + .hexpand(true) + .css_classes(vec!["stack".to_string()]) + .build(); + let stack_header = HeaderBar::builder().build(); + let stack_nav_left_button = Button::from_icon_name("go-previous-symbolic"); + stack_box.append(&stack_header); + stack_box.append(&stack); + + sections.append(&sidebar_box); + sections.append(&stack_box); + sections.set_visible_child(&stack_box); + + sidebar_nav_right_button.connect_clicked( + glib::clone!(@weak sections, @weak stack_box => move |_| { + sections.set_visible_child(&stack_box); + }), + ); + stack_nav_left_button.connect_clicked( + glib::clone!(@weak sections, @weak sidebar_box => move |_| { + sections.set_visible_child(&sidebar_box); + }), + ); + + // This is to be used in `connect_folded_notify` below, but we extract it into a + // separate closure so we can call it once before the UI is shown. + let folded_notify = glib::clone!(@weak sections, @weak sidebar_header, @weak stack_header, @weak sidebar_nav_right_button, @weak sidebar_menu_button, @weak stack_nav_left_button => move || { + if sections.is_folded() { + sidebar_header.remove(&sidebar_menu_button); + sidebar_header.pack_end(&sidebar_nav_right_button); + sidebar_header.pack_end(&sidebar_menu_button); + stack_header.pack_start(&stack_nav_left_button); + } else { + sidebar_header.remove(&sidebar_menu_button); + stack_header.remove(&stack_nav_left_button); + } + }); + sections.connect_folded_notify(glib::clone!(@strong folded_notify => move |_| { + folded_notify(); + })); + folded_notify(); + + sections.set_visible_child(&sidebar_box); + window.set_content(Some(§ions)); + + // Show the window and start syncing. + window.show(); + + 'main: loop { + // If the user requested to open the window, then open it. + let notify_file = util::notify_open_file(); + if notify_file.exists() { + window.present(); + fs::remove_file(¬ify_file).unwrap(); + } + + // If the user requested to quit the application, then break the loop. + if *quit_request.get_ref() { + break 'main; + } + + // Continue with syncing. + let remotes = util::await_future(RemotesEntity::find().all(&db)).unwrap(); + + // If no remotes are present we need to close the window and ask the user to log + // in again. + if remotes.is_empty() { + window.close(); + + if login::login(app, &db).is_none() { + break 'main; + } else { + window.show(); + continue; + } + } + + util::run_in_background(|| thread::sleep(Duration::from_millis(500))); + + for remote in remotes { + // Process any remote deletion requests. + { + let mut remote_queue = remote_deletion_queue.get_mut_ref(); + + while !remote_queue.is_empty() { + let remote_name = remote_queue.remove(0); + + // Remove the item from the UI. + let child = stack.child_by_name(&remote_name).unwrap(); + stack.remove(&child); + + // Delete all related database entries. + util::await_future(async { + let db_remote = RemotesEntity::find() + .filter(RemotesColumn::Name.eq(remote_name.clone())) + .one(&db) + .await + .unwrap() + .unwrap(); + let sync_dirs = SyncDirsEntity::find() + .filter(SyncDirsColumn::RemoteId.eq(db_remote.id)) + .all(&db) + .await + .unwrap(); + + for sync_dir in sync_dirs { + SyncItemsEntity::delete_many() + .filter(SyncItemsColumn::SyncDirId.eq(sync_dir.id)) + .exec(&db) + .await + .unwrap(); + sync_dir.delete(&db).await.unwrap(); + } + + db_remote.delete(&db).await.unwrap(); + }); + + // Delete the Rclone config. + rclone::sync::delete_config(&remote_name).unwrap(); + } + } + + let sync_dirs = util::await_future( + SyncDirsEntity::find() + .filter(SyncDirsColumn::RemoteId.eq(remote.id)) + .all(&db), + ) + .unwrap(); + + for sync_dir in sync_dirs { + let item_ptr = directory_map.get_ref(); + let item = item_ptr + .get(&remote.name) + .unwrap() + .get(&(sync_dir.local_path.clone(), sync_dir.remote_path.clone())) + .unwrap(); + + // If we have pending errors that need resolved, don't sync this directory. + if item.error_status_text.text().len() != 0 { + continue; + } + + // Set up the UI for notifying the user that this directory is being synced. + // The width/height and margins for this are based on those from `get_image()` + // at the top of this file, as they're placed at the same place in the UI. + let spinner = Spinner::builder() + .spinning(true) + .width_request(4) + .height_request(4) + .margin_start(3) + .margin_end(3) + .build(); + item.status_icon.set_child(Some(&spinner)); + item.status_text.set_label("Checking for changes..."); + // Dropping this is important, otherwise the pointer borrow might last a lot + // longer and other parts of the code won't be able to get a pointer to the + // directory indexmap. + drop(item_ptr); + + // Add an error for reporting in the UI. + static PLEASE_RESOLVE_MSG: &str = " Please resolve the reported syncing issues."; + let add_error = glib::clone!(@strong db, @strong directory_map, @strong remote, @strong sync_dir => move |error: SyncError| { + let path_pair = (sync_dir.local_path.clone(), sync_dir.remote_path.clone()); + let ui_item = error.generate_ui(); + let ui_item_listbox = ListBoxRow::builder().child(&ui_item).build(); + + // Generate the callback. + let gesture = GestureClick::new(); + gesture.connect_released(glib::clone!(@strong directory_map, @strong remote, @strong path_pair, @strong db, @strong error, @weak ui_item, @weak ui_item_listbox => move |_, _, _, _| { + ui_item.set_sensitive(false); + let remove_ui_item = glib::clone!(@strong directory_map, @strong remote, @strong path_pair, @strong error, @weak ui_item_listbox => move || { + let mut ptr = directory_map.get_mut_ref(); + let item = ptr.get_mut(&remote.name).unwrap().get_mut(&path_pair).unwrap(); + + // Update the error brief on the main page. + let error_text = item.error_status_text.text().to_string(); + let new_num_errors = error_text.chars().next().unwrap().to_digit(10).unwrap() - 1; + if new_num_errors == 0 { + item.error_status_text.set_label(""); + item.status_text.set_label(item.status_text.text().as_str().strip_suffix(PLEASE_RESOLVE_MSG).unwrap()); + } else { + let error_string = format!("{new_num_errors} errors found. "); + item.error_status_text.set_label(&error_string); + } + + // Update the sync dir's page and our code. + item.error_items.remove(&error).unwrap(); + item.error_list.remove(&ui_item_listbox); + }); + + match &error { + SyncError::General(_, _) => { + let dialog = MessageDialog::builder() + .title(&util::get_title!("Sync Error")) + .text("Would you like to dismiss this error?") + .buttons(ButtonsType::YesNo) + .build(); + dialog.connect_close_request(glib::clone!(@strong ui_item => move |_| { + ui_item.set_sensitive(true); + Inhibit(false) + })); + dialog.connect_response(glib::clone!(@strong directory_map, @strong remote, @strong path_pair, @weak ui_item, @strong error, @strong remove_ui_item => move |dialog, resp| { + match resp { + ResponseType::Yes => { + remove_ui_item(); + }, + ResponseType::No => { + ui_item.set_sensitive(true); + }, + _ => return, + } + + dialog.close(); + })); + dialog.show(); + }, + SyncError::BothMoreCurrent(local_item, remote_item) => { + let local_item_formatted = util::fmt_home(local_item); + let local_path = Path::new(&local_item); + let sync_local_to_remote = glib::clone!(@strong remote, @strong local_item_formatted, @strong local_item, @strong remote_item => move || { + if let Err(err) = rclone::sync::copy_to_remote(&local_item, &remote.name, &remote_item) { + gtk_util::show_error("Sync Error", &format!("Failed to sync '{local_item_formatted}' to '{remote_item}' on remote."), Some(&err.error)); + Err(()) + } else { + Ok(()) + } + }); + let sync_remote_to_local = glib::clone!(@strong remote, @strong local_item_formatted, @strong local_item, @strong remote_item => move || { + if let Err(err) = rclone::sync::copy_to_local(&local_item, &remote.name, &remote_item) { + gtk_util::show_error("Sync Error", &format!("Failed to sync '{remote_item}' on remote to {local_item_formatted}."), Some(&err.error)); + Err(()) + } else { + Ok(()) + } + }); + let local_item = local_item.clone(); + let update_db_item = glib::clone!(@strong db, @strong remote, @strong local_item, @strong remote_item => move || { + let local_timestamp = Path::new(&local_item).metadata().unwrap().modified().unwrap().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs(); + let remote_timestamp = rclone::sync::stat(&remote.name, &remote_item).unwrap().unwrap().mod_time.unix_timestamp(); + let mut active_model: SyncItemsActiveModel = util::await_future(SyncItemsEntity::find() + .filter(SyncItemsColumn::LocalPath.eq(local_item.clone())) + .filter(SyncItemsColumn::RemotePath.eq(remote_item.clone())) + .one(&db) + ).unwrap() + .unwrap() + .into(); + active_model.last_local_timestamp = ActiveValue::set(local_timestamp.try_into().unwrap()); + active_model.last_remote_timestamp = ActiveValue::Set(remote_timestamp.try_into().unwrap()); + util::await_future(active_model.update(&db)).unwrap(); + }); + let rclone_remote_item = match rclone::sync::stat(&remote.name, remote_item) { + Ok(item) => item, + Err(err) => { + gtk_util::show_error( + "Remote Item Fetch Error", + &format!("Unable to fetch data for '{remote_item}' from the remote."), + Some(&err.error) + ); + return; + } + }; + + // If neither the local item or the remote item exist anymore, this error is no longer relevant. + if !local_path.exists() && rclone_remote_item.is_none() { + gtk_util::show_error("File Update", "File Update", Some("Neither the local item or remote item exists anymore. This error will now be removed.")); + remove_ui_item(); + return; + // Otherwise if only the local exists, use that. + } else if local_path.exists() && rclone_remote_item.is_none() { + gtk_util::show_error("File Update", "File Update", Some("Only the local item exists now, so it will be synced to the remote.")); + if sync_local_to_remote().is_ok() { + update_db_item(); + remove_ui_item(); + return; + } + // Otherwise if only the remote exists, use that. + } else if !local_path.exists() && rclone_remote_item.is_some() { + gtk_util::show_error("File Update", "File Update", Some("Only the remote item exists now, so it will be synced to the local machine.")); + if sync_remote_to_local().is_ok() { + update_db_item(); + remove_ui_item(); + return; + } + } + + let dialog = MessageDialog::builder() + .title(&util::get_title!("Sync Error")) + .text( + &format!("Both the local item '{local_item_formatted}' and remote item '{remote_item}' have been updated since the last sync.") + ) + .secondary_text("Which item would you like to keep?") + .build(); + dialog.add_button("Local", ResponseType::Other(0)); + dialog.add_button("Remote", ResponseType::Other(1)); + dialog.connect_close_request(glib::clone!(@strong ui_item => move |_| { + ui_item.set_sensitive(true); + Inhibit(false) + })); + dialog.connect_response(glib::clone!(@strong directory_map, @strong remote, @strong path_pair, @weak ui_item, @strong error, @strong local_item, @strong remote_item, @strong local_path, @strong rclone_remote_item, @strong sync_local_to_remote, @strong sync_remote_to_local => move |dialog, resp| { + match resp { + ResponseType::Other(0) => { + if sync_local_to_remote().is_ok() { + update_db_item(); + remove_ui_item(); + } + }, + ResponseType::Other(1) => { + if sync_remote_to_local().is_ok() { + update_db_item(); + remove_ui_item(); + } + }, + ResponseType::Other(_) => unreachable!(), + _ => return + } + + dialog.close(); + })); + + dialog.show(); + } + } + })); + ui_item.add_controller(&gesture); + + // Report the brief on the number of errors. + let mut ptr = directory_map.get_mut_ref(); + let item = ptr + .get_mut(&remote.name) + .unwrap() + .get_mut(&path_pair) + .unwrap(); + + let error_text = item.error_status_text.text().to_string(); + if error_text.is_empty() { + item.error_status_text.set_label("1 error found. "); + } else { + let num_errors = error_text.chars().next().unwrap().to_digit(10).unwrap(); + let error_string = format!("{} errors found. ", num_errors + 1); + item.error_status_text.set_label(&error_string); + } + + item.error_list.append(&ui_item_listbox); + item.error_items.insert(error, ui_item); + }); + + // A vector of local/remote sync item pairs to make sure we don't sync anything + // twice between 'sync_local_directory' and 'sync_remote_directory' below. It + // also prevents errors from showing up twice when they occur. We have to wrap + // this in a [`RefCell`] to avoid some borrow checker issues with multiple + // mutable closures needing access to this. + let synced_items: RefCell> = RefCell::new(vec![]); + + // Get any pending deletion requests and process them. + let process_deletion_requests = glib::clone!(@strong db, @weak stack, @strong directory_map, @strong remote_deletion_queue, @strong sync_dir_deletion_queue => move || { + let mut dmap = directory_map.get_mut_ref(); + let mut remote_queue = remote_deletion_queue.get_mut_ref(); + let mut dir_queue = sync_dir_deletion_queue.get_mut_ref(); + + // Process directory deletions. + while !dir_queue.is_empty() { + let queue_item = dir_queue.remove(0); + let dir_pair = (queue_item.1.clone(), queue_item.2.clone()); + let ui_item = dmap.get(&queue_item.0).unwrap().get(&dir_pair).unwrap(); + + // Remove the item from the UI. + ui_item.parent_list.remove(&ui_item.container); + + // Remove the item from the directory map. + dmap.get_mut(&queue_item.0).unwrap().remove(&dir_pair).unwrap(); + + // Remove the item from the database. + util::await_future(async { + let sync_dir = SyncDirsEntity::find() + .filter(SyncDirsColumn::LocalPath.eq(queue_item.1.clone())) + .filter(SyncDirsColumn::RemotePath.eq(queue_item.2.clone())) + .one(&db) + .await + .unwrap() + .unwrap(); + + SyncItemsEntity::delete_many() + .filter(SyncItemsColumn::SyncDirId.eq(sync_dir.id)) + .exec(&db) + .await + .unwrap(); + sync_dir.delete(&db).await.unwrap(); + }); + } + + // Process remote deletions. + while !remote_queue.is_empty() { + let remote_name = remote_queue.remove(0); + + // Remove the item from the UI. + let child = stack.child_by_name(&remote_name).unwrap(); + stack.remove(&child); + + // Delete all related database entries. + util::await_future(async { + let db_remote = RemotesEntity::find() + .filter(RemotesColumn::Name.eq(remote_name.clone())) + .one(&db) + .await + .unwrap() + .unwrap(); + let sync_dirs = SyncDirsEntity::find() + .filter(SyncDirsColumn::RemoteId.eq(db_remote.id)) + .all(&db) + .await + .unwrap(); + + for sync_dir in sync_dirs { + SyncItemsEntity::delete_many() + .filter(SyncItemsColumn::SyncDirId.eq(sync_dir.id)) + .exec(&db) + .await + .unwrap(); + sync_dir.delete(&db).await.unwrap(); + } + + db_remote.delete(&db).await.unwrap(); + }); + + // Delete the Rclone config. + rclone::sync::delete_config(&remote_name).unwrap(); + } + }); + + // Sync a local directory. This is implemented as a function instead of a + // closure so that it can be called recursively. + // + // Returning an [`Err<()>`] means we this directory has to stop being synced + // because it was in the deletion queue. Any other error should return an + // [`Ok<()>`]. + #[allow(clippy::too_many_arguments)] + fn sync_local_directory( + local_dir: &Path, + remote: &RemotesModel, + sync_dir: &SyncDirsModel, + db: &DatabaseConnection, + directory_map: &DirectoryMap, + synced_items: &RefCell>, + quit_request: &Rc>, + add_error: F1, + process_deletion_requests: F2, + ) { + process_deletion_requests(); + + let dir_string = local_dir.to_str().unwrap().to_owned(); + let update_ui_progress = || { + // If this directory no longer exists in the database (i.e. from being + // deleted from the `sync_dir_deletion_queue`, do nothing). + if !sync_dir.exists(db) { + return; + } + + let ptr = directory_map.get_ref(); + let dir_pair = (sync_dir.local_path.clone(), sync_dir.remote_path.clone()); + let item = ptr.get(&remote.name).unwrap().get(&dir_pair).unwrap(); + let status_string = + format!("Checking '{}' for changes...", util::fmt_home(&dir_string)); + item.status_text.set_label(&status_string); + }; + update_ui_progress(); + let directory = match fs::read_dir(local_dir) { + Ok(ok_dir) => ok_dir, + Err(err) => { + add_error(SyncError::General(dir_string.clone(), err.to_string())); + return; + } + }; + + // Get the list of ignore globs. + let ignore_file_string = + format!("{}/{}", sync_dir.local_path, FILE_IGNORE_NAME); + let ignore_file_path = Path::new(&ignore_file_string); + let ignore_globs = if ignore_file_path.exists() { + let _lock = FileLock::lock( + &ignore_file_string, + true, + FileOptions::new().write(true).read(true), + ) + .unwrap(); + let file_content = fs::read_to_string(ignore_file_path).unwrap(); + let mut globs = vec![]; + + for line in file_content.lines() { + if let Ok(pattern) = glob::Pattern::new(line) { + globs.push(pattern); + } + } + + globs + } else { + vec![] + }; + + for item in directory { + // If a close request was sent in, stop syncing this remote so we can quit + // the application in the 'main loop. + if *quit_request.get_ref() { + break; + } + + // If this directory no longer exists in the database (i.e. from being + // deleted from the `sync_dir_deletion_queue`), stop processing and return. + if !sync_dir.exists(db) { + break; + } + + if let Err(err) = item { + add_error(SyncError::General(dir_string.clone(), err.to_string())); + continue; + } + let item = item.unwrap(); + let local_path = item.path().to_str().unwrap().to_owned(); + // The path from the root of the remote. + let remote_path = { + let local_path_stripped = local_path + .strip_prefix(&format!("{}/", sync_dir.local_path)) + .unwrap(); + let stripped_path = match local_path_stripped.strip_suffix('/') { + Some(string) => string, + None => local_path_stripped, + }; + sync_dir.remote_path.clone() + "/" + stripped_path + }; + // The above path, with `sync_dir.remote_path` stripped from it. + let stripped_remote_path = remote_path + .strip_prefix(&format!("{}/", sync_dir.remote_path)) + .unwrap() + .to_owned(); + + // If this item matches the ignore list, don't sync it. + if ignore_globs + .iter() + .filter(|pattern| pattern.matches(&stripped_remote_path)) + .count() + > 0 + { + continue; + } + + synced_items + .borrow_mut() + .push((local_path.clone(), remote_path.clone())); + + let get_local_file_timestamp = || { + item.metadata() + .unwrap() + .modified() + .unwrap() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs() + }; + let local_utc_timestamp = get_local_file_timestamp(); + let remote_item = match rclone::sync::stat(&remote.name, &remote_path) { + Ok(item) => item, + Err(err) => { + add_error(SyncError::General(remote_path.clone(), err.error)); + continue; + } + }; + let remote_utc_timestamp = remote_item + .as_ref() + .map(|item| item.mod_time.unix_timestamp()); + let db_item = util::await_future( + SyncItemsEntity::find() + .filter(SyncItemsColumn::LocalPath.eq(local_path.clone())) + .filter(SyncItemsColumn::RemotePath.eq(remote_path.clone())) + .one(db), + ) + .unwrap(); + + // Push the item to the remote. Returns the + // [`crate::rclone::sync::RcloneRemoteItem`] of the item on the remote, or + // an [`Err<()>`] if an issue occured (all errors are automatically added + // via `add_errors`). + let push_local_to_remote = || -> Result { + let file_type = item.file_type().unwrap(); + + if let Some(rclone_item) = &remote_item { + let same_type = file_type.is_dir() && rclone_item.is_dir; + + if !same_type { + if let Err(err) = + rclone::sync::purge(&remote.name, &remote_path) + { + add_error(SyncError::General( + remote_path.clone(), + err.error, + )); + return Err(()); + } + } + } + + if file_type.is_dir() { + if let Err(err) = rclone::sync::mkdir(&remote.name, &remote_path) { + add_error(SyncError::General(remote_path.clone(), err.error)); + return Err(()); + } + sync_local_directory( + &item.path(), + remote, + sync_dir, + db, + directory_map, + synced_items, + quit_request, + add_error.clone(), + process_deletion_requests.clone(), + ); + update_ui_progress(); + } else if let Err(err) = rclone::sync::copy_to_remote( + &local_path, + &remote.name, + &remote_path, + ) { + add_error(SyncError::General(local_path.clone(), err.error)); + return Err(()); + } + + Ok(rclone::sync::stat(&remote.name, &remote_path) + .unwrap() + .unwrap()) + }; + // Pull the item from the remote. + let pull_remote_to_local = || -> Result<(), ()> { + let file_type = item.file_type().unwrap(); + let same_type = + file_type.is_dir() && remote_item.as_ref().unwrap().is_dir; + + if !same_type { + if file_type.is_dir() && let Err(err) = fs::remove_dir_all(item.path()) { + add_error(SyncError::General(local_path.clone(), err.to_string())); + return Err(()); + } else if let Err(err) = fs::remove_file(item.path()) { + add_error(SyncError::General(local_path.clone(), err.to_string())); + return Err(()); + } + } + + if file_type.is_dir() { + sync_local_directory( + &item.path(), + remote, + sync_dir, + db, + directory_map, + synced_items, + quit_request, + add_error.clone(), + process_deletion_requests.clone(), + ); + update_ui_progress(); + } else if let Err(err) = + rclone::sync::copy_to_local(&local_path, &remote.name, &remote_path) + { + add_error(SyncError::General(remote_path.clone(), err.error)); + return Err(()); + } + + Ok(()) + }; + // Delete this item from the database. + let delete_db_entry = || { + util::await_future(async { + SyncItemsEntity::find() + .filter(SyncItemsColumn::SyncDirId.eq(sync_dir.id)) + .filter(SyncItemsColumn::LocalPath.eq(local_path.clone())) + .filter(SyncItemsColumn::RemotePath.eq(remote_path.clone())) + .one(db) + .await + .unwrap() + .unwrap() + .delete(db) + .await + .unwrap() + }) + }; + + // If we have a record of the last sync, use that to aid in timestamp + // checks. + if let Some(db_model) = db_item { + let update_db_item = |local_timestamp, remote_timestamp| { + let mut active_model: SyncItemsActiveModel = + db_model.clone().into(); + active_model.last_local_timestamp = + ActiveValue::Set(local_timestamp); + active_model.last_remote_timestamp = + ActiveValue::Set(remote_timestamp); + util::await_future(active_model.update(db)).unwrap(); + }; + + // Both items are more current than at the last transaction - we need to + // let the user decide which to keep. + // Since `db_model.last_sync_timestamp` is an `i32`, we should be able + // to safely convert it to an `i64` and `u64`. + if local_utc_timestamp > db_model.last_local_timestamp as u64 && let Some(remote_timestamp) = remote_utc_timestamp && remote_timestamp > db_model.last_remote_timestamp as i64 { + // Only add the error if one of the items is not a directory - there's no point in saying both directories are more current, and it's probably because one of the items in the directory got updated anyway. + if let Some(r_item) = remote_item && (!item.path().is_dir() || !r_item.is_dir) { + add_error(SyncError::BothMoreCurrent(local_path.clone(), remote_path.clone())); + } + // The local item is more recent. + } else if local_utc_timestamp > db_model.last_local_timestamp as u64 { + if let Ok(rclone_item) = push_local_to_remote() { + update_db_item(get_local_file_timestamp().try_into().unwrap(), rclone_item.mod_time.unix_timestamp().try_into().unwrap()); + continue; + } else { + continue; + } + // The remote item is more recent. + } else if let Some(remote_timestamp) = remote_utc_timestamp && remote_timestamp > db_model.last_remote_timestamp as i64 { + if pull_remote_to_local().is_err() { + continue; + } else { + update_db_item(get_local_file_timestamp().try_into().unwrap(), remote_timestamp.try_into().unwrap()); + } + // The item is missing from the remote, but the last recorded timestamp for the local item is still the same. This means the item got deleted on the server, and we need to reflect such locally. + } else if remote_item.is_none() && local_utc_timestamp == db_model.last_local_timestamp as u64 { + if item.path().is_dir() { + if let Err(err) = fs::remove_dir_all(&local_path) { + add_error(SyncError::General(local_path.clone(), err.to_string())); + continue; + } + } else if let Err(err) = fs::remove_file(&local_path) { + add_error(SyncError::General(local_path.clone(), err.to_string())); + continue; + } + + delete_db_entry(); + continue; + // Both the local and remote item remain unchanged - do nothing. + } else if local_utc_timestamp == db_model.last_local_timestamp as u64 && let Some(remote_timestamp) = remote_utc_timestamp && remote_timestamp == db_model.last_remote_timestamp as i64 { + continue; + // Every possible scenario should have been convered above, so panic if not. + } else { + unreachable!(); + } + // Otherwise just check the local timestamps against + // those on the remote, and record our new transaction + // in the database. + } else { + // If the timestamp exists, then the remote item did, so check + // timestamps. + if let Some(remote_timestamp) = remote_utc_timestamp { + if local_utc_timestamp > remote_timestamp as u64 { + if push_local_to_remote().is_err() { + continue; + } + } else if pull_remote_to_local().is_err() { + continue; + } + // Otherwise the remote item didn't exist, so just + // sync our local copy. + } else if push_local_to_remote().is_err() { + continue; + } + + // The remote item is now guaranteed to exist, so fetch it. + let remote_item_safe = + match rclone::sync::stat(&remote.name, &remote_path) { + Ok(item) => item.unwrap(), + Err(err) => { + add_error(SyncError::General( + remote_path.clone(), + err.error, + )); + continue; + } + }; + match rclone::sync::stat(&remote.name, &remote_path) { + Ok(item) => item.unwrap(), + Err(err) => { + add_error(SyncError::General(remote_path.clone(), err.error)); + continue; + } + }; + + // Record the current transaction's timestamps in the database. + util::await_future( + SyncItemsActiveModel { + sync_dir_id: ActiveValue::Set(sync_dir.id), + local_path: ActiveValue::Set(local_path.clone()), + remote_path: ActiveValue::Set(remote_path.clone()), + last_local_timestamp: ActiveValue::Set( + local_utc_timestamp.try_into().unwrap(), + ), + last_remote_timestamp: ActiveValue::Set( + remote_item_safe + .mod_time + .unix_timestamp() + .try_into() + .unwrap(), + ), + ..Default::default() + } + .insert(db), + ) + .unwrap(); + } + } + } + + // Sync a remote directory. It's implemented as a function because of the same + // logic for `fn sync_local_directory` above. + // - NOTE: `remote_dir` should be: 1. the path with any `/` prefix/suffix + // removed 2. the full path from the root of the remote server. + #[allow(clippy::too_many_arguments)] + fn sync_remote_directory( + remote_dir: &str, + remote: &RemotesModel, + sync_dir: &SyncDirsModel, + db: &DatabaseConnection, + directory_map: &DirectoryMap, + synced_items: &RefCell>, + quit_request: &Rc>, + add_error: F1, + process_deletion_requests: F2, + ) { + process_deletion_requests(); + + let ignore_file_string = + format!("{}/{}", sync_dir.local_path, FILE_IGNORE_NAME); + let ignore_file_path = Path::new(&ignore_file_string); + let ignore_globs = if ignore_file_path.exists() { + let _lock = FileLock::lock( + ignore_file_path, + true, + FileOptions::new().write(true).read(true), + ) + .unwrap(); + let file_content = fs::read_to_string(ignore_file_path).unwrap(); + let mut globs = vec![]; + + for line in file_content.lines() { + if let Ok(pattern) = glob::Pattern::new(line) { + globs.push(pattern); + } + } + + globs + } else { + vec![] + }; + let update_ui_progress = || { + // If this directory no longer exists in the database (i.e. from being + // deleted from the `sync_dir_deletion_queue`, do nothing). + if !sync_dir.exists(db) { + return; + } + + let ptr = directory_map.get_ref(); + let dir_pair = (sync_dir.local_path.clone(), sync_dir.remote_path.clone()); + let item = ptr.get(&remote.name).unwrap().get(&dir_pair).unwrap(); + let status_string = + format!("Checking '{remote_dir}' on remote for changes..."); + item.status_text.set_label(&status_string); + }; + update_ui_progress(); + let items = match rclone::sync::list( + &remote.name, + remote_dir, + false, + RcloneListFilter::All, + ) { + Ok(ok_items) => ok_items, + Err(err) => { + add_error(SyncError::General(remote_dir.to_owned(), err.error)); + return; + } + }; + + for item in items { + // If a close request was sent in, stop syncing this remote so we can quit + // the application in the 'main loop. + if *quit_request.get_ref() { + break; + } + + // If this directory no longer exists in the database (i.e. from being + // deleted from the `sync_dir_deletion_queue`), stop processing and return. + if !sync_dir.exists(db) { + break; + } + + // If this item matches the ignore filter, don't sync it. + if ignore_globs + .iter() + .filter(|pattern| pattern.matches(&item.path)) + .count() + > 0 + { + continue; + } + + let remote_path_string = item.path.clone(); + let local_path_string = format!( + "{}{}", + sync_dir.local_path, + item.path.strip_prefix(&sync_dir.remote_path).unwrap() + ); + // If we've already synced this directory from `fn sync_local_directory` + // above, don't sync it again. + if synced_items + .borrow() + .contains(&(local_path_string.clone(), remote_path_string.clone())) + { + continue; + } + + let local_path = Path::new(&local_path_string); + let remote_timestamp = item.mod_time.unix_timestamp(); + let get_local_file_timestamp = || { + local_path.metadata().ok().map(|metadata| { + metadata + .modified() + .unwrap() + .duration_since(SystemTime::UNIX_EPOCH) + .unwrap() + .as_secs() + }) + }; + let local_timestamp = get_local_file_timestamp(); + let db_item = util::await_future( + SyncItemsEntity::find() + .filter(SyncItemsColumn::LocalPath.eq(local_path_string.clone())) + .filter(SyncItemsColumn::RemotePath.eq(remote_path_string.clone())) + .one(db), + ) + .unwrap(); + + // Push the item from the local machine to the remote machine. Returns the + // timestamp of the new file on the remote. Returns the + // [`crate::rclone::sync::RcloneRemoteItem`] of the item on the remote, or + // an [`Err<()>`] if an issue occured (all errors are automatically added + // via `add_errors`). + let push_local_to_remote = || { + if local_path.is_dir() { + if !item.is_dir { + if let Err(err) = + rclone::sync::delete(&remote.name, &remote_path_string) + { + add_error(SyncError::General( + remote_path_string.clone(), + err.error, + )); + return Err(()); + } + + if let Err(err) = + rclone::sync::mkdir(&remote.name, &remote_path_string) + { + add_error(SyncError::General( + remote_path_string.clone(), + err.error, + )); + return Err(()); + } + } + + sync_remote_directory( + &item.path, + remote, + sync_dir, + db, + directory_map, + synced_items, + quit_request, + add_error.clone(), + process_deletion_requests.clone(), + ); + update_ui_progress(); + } else { + if item.is_dir { + if let Err(err) = + rclone::sync::purge(&remote.name, &remote_path_string) + { + add_error(SyncError::General( + remote_path_string.clone(), + err.error, + )); + return Err(()); + } + } + + if let Err(err) = rclone::sync::copy_to_remote( + &local_path_string, + &remote.name, + &remote_path_string, + ) { + add_error(SyncError::General( + remote_path_string.clone(), + err.error, + )); + return Err(()); + } + } + + Ok(rclone::sync::stat(&remote.name, &remote_path_string) + .unwrap() + .unwrap()) + }; + + // Pull the item from the remote to the local machine. + let pull_remote_to_local = || { + // Make sure file types match up. + if local_path.exists() { + if local_path.is_dir() && !item.is_dir { + if let Err(err) = fs::remove_dir_all(local_path) { + add_error(SyncError::General( + local_path_string.clone(), + err.to_string(), + )); + return Err(()); + } + } else if !local_path.is_dir() && item.is_dir { + if let Err(err) = fs::remove_file(local_path) { + add_error(SyncError::General( + local_path_string.clone(), + err.to_string(), + )); + return Err(()); + } + + if let Err(err) = fs::create_dir(local_path) { + add_error(SyncError::General( + local_path_string.clone(), + err.to_string(), + )); + return Err(()); + } + } + } + + if item.is_dir { + if !local_path.exists() && let Err(err) = fs::create_dir(local_path) { + add_error(SyncError::General(local_path_string.clone(), err.to_string())); + return Err(()); + } + + sync_remote_directory( + &item.path, + remote, + sync_dir, + db, + directory_map, + synced_items, + quit_request, + add_error.clone(), + process_deletion_requests.clone(), + ); + update_ui_progress(); + } else if let Err(err) = rclone::sync::copy_to_local( + &local_path_string, + &remote.name, + &remote_path_string, + ) { + add_error(SyncError::General( + remote_path_string.clone(), + err.error, + )); + return Err(()); + } + + Ok(()) + }; + // Delete this item from the database. + let delete_db_entry = || { + util::await_future(async { + SyncItemsEntity::find() + .filter(SyncItemsColumn::SyncDirId.eq(sync_dir.id)) + .filter( + SyncItemsColumn::LocalPath.eq(local_path_string.clone()), + ) + .filter( + SyncItemsColumn::RemotePath.eq(remote_path_string.clone()), + ) + .one(db) + .await + .unwrap() + .unwrap() + .delete(db) + .await + .unwrap() + }) + }; + + // If we have a database record, use that in checks. + if let Some(db_model) = db_item { + let update_db_item = |local_timestamp, remote_timestamp| { + let mut active_model: SyncItemsActiveModel = + db_model.clone().into(); + active_model.last_local_timestamp = + ActiveValue::Set(local_timestamp); + active_model.last_remote_timestamp = + ActiveValue::Set(remote_timestamp); + util::await_future(active_model.update(db)).unwrap(); + }; + + // Both items are more recent. + if let Some(l_timestamp) = local_timestamp && l_timestamp > db_model.last_local_timestamp as u64 && remote_timestamp > db_model.last_remote_timestamp as i64 { + // Only add the error if one of the items is not a directory - there's no point in saying both directories are more current, and it's probably because one of the items in the directory got updated anyway. + if !local_path.is_dir() || !item.is_dir { + add_error(SyncError::BothMoreCurrent(local_path_string.clone(), remote_path_string.clone())); + } + continue; + // The local item is more recent. + } else if let Some(l_timestamp) = local_timestamp && l_timestamp > db_model.last_local_timestamp as u64 { + if let Ok(rclone_item) = push_local_to_remote() { + update_db_item(get_local_file_timestamp().unwrap().try_into().unwrap(), rclone_item.mod_time.unix_timestamp().try_into().unwrap()); + continue; + } else { + continue; + } + + // The remote item is more recent. + } else if remote_timestamp > db_model.last_remote_timestamp as i64 { + if pull_remote_to_local().is_err() { + continue; + } else { + update_db_item(get_local_file_timestamp().unwrap().try_into().unwrap(), remote_timestamp.try_into().unwrap()); + } + + // The item is missing locally, but the last recorded timestamp for the remote item is still the same. This means the item got deleted locally, and we need to reflect such on the server. + } else if !local_path.exists() && remote_timestamp == db_model.last_remote_timestamp as i64 { + if let Err(err) = rclone::sync::purge(&remote.name, &remote_path_string) { + add_error(SyncError::General(remote_path_string.clone(), err.error)); + delete_db_entry(); + continue; + } else { + continue; + } + + // Both the local and remote item remain unchanged - do nothing. + } else if let Some(l_timestamp) = local_timestamp && l_timestamp == db_model.last_local_timestamp as u64 && remote_timestamp == db_model.last_remote_timestamp as i64 { + continue; + + // Every possible scenario should have been covered above, so panic if not. + } else { + unreachable!(); + } + // Otherwise just check the local timestamps against + // those on th remote, and record our new transaction in + // the database. + } else { + // If the local timestamp exists, then compare local and remote + // timestamps. + if let Some(l_timestamp) = local_timestamp { + if l_timestamp > remote_timestamp as u64 { + if push_local_to_remote().is_err() { + continue; + } + } else if pull_remote_to_local().is_err() { + continue; + } + + // Otherwise the local item didn't exist, so just + // sync it from the remote. + } else if pull_remote_to_local().is_err() { + continue; + } + } + + // The local item is now guaranteed to exist. Also fetch the remote's + // timestamp in case it got updated above. + let l_timestamp = get_local_file_timestamp().unwrap(); + let r_timestamp = + match rclone::sync::stat(&remote.name, &remote_path_string) { + Ok(item) => item.unwrap().mod_time.unix_timestamp(), + Err(err) => { + add_error(SyncError::General( + remote_path_string.clone(), + err.error, + )); + continue; + } + }; + + // Record the current transaction's timestamps in the database. + util::await_future( + SyncItemsActiveModel { + sync_dir_id: ActiveValue::Set(sync_dir.id), + local_path: ActiveValue::Set(local_path_string.clone()), + remote_path: ActiveValue::Set(remote_path_string.clone()), + last_local_timestamp: ActiveValue::Set( + l_timestamp.try_into().unwrap(), + ), + last_remote_timestamp: ActiveValue::Set( + r_timestamp.try_into().unwrap(), + ), + ..Default::default() + } + .insert(db), + ) + .unwrap(); + } + } + + sync_local_directory( + Path::new(&sync_dir.local_path), + &remote, + &sync_dir, + &db, + &directory_map, + &synced_items, + &quit_request, + &add_error, + &process_deletion_requests, + ); + sync_remote_directory( + &sync_dir.remote_path, + &remote, + &sync_dir, + &db, + &directory_map, + &synced_items, + &quit_request, + &add_error, + &process_deletion_requests, + ); + + // If a close request was sent in, quit. + if *quit_request.get_ref() { + break 'main; + } + + // If this sync directory doesn't exist anymore (from being deleted during + // `process_deletion_requests` calls in the about two functions), go to the next + // sync directory. + if !sync_dir.exists(&db) { + continue; + } + + // Set up the UI for notifying the user that this directory has been synced. + let item_ptr = directory_map.get_ref(); + let item = item_ptr + .get(&remote.name) + .unwrap() + .get(&(sync_dir.local_path.clone(), sync_dir.remote_path.clone())) + .unwrap(); + item.status_icon + .set_child(Some(&get_image("object-select-symbolic"))); + let mut finished_text = "Directory has finished sync checks.".to_string(); + if item.error_status_text.text().len() != 0 { + finished_text += PLEASE_RESOLVE_MSG; + item.status_icon + .set_child(Some(&get_image("dialog-warning-symbolic"))); + } else { + item.status_icon + .set_child(Some(&get_image("object-select-symbolic"))); + } + item.status_text.set_label(&finished_text); + drop(item_ptr); + } + } + } + + // We broke out of the loop because of a close request, so close the window. + window.close(); +} diff --git a/src/login/dropbox.rs b/src/login/dropbox.rs new file mode 100644 index 0000000..3b4e63c --- /dev/null +++ b/src/login/dropbox.rs @@ -0,0 +1,105 @@ +//! The data for a Nextcloud Rclone config. +use super::{login_util, ServerType}; +use crate::{gtk_util, mpsc::Sender, traits::*, util}; +use adw::{glib, gtk::Button, prelude::*, ApplicationWindow, EntryRow, MessageDialog}; +use std::{ + cell::RefCell, + io::Read, + process::{Command, Stdio}, + rc::Rc, + thread, + time::Duration, +}; + +static DEFAULT_CLIENT_ID: &str = "hke0fgr43viaq03"; +static DEFAULT_CLIENT_SECRET: &str = "o4cpx8trcnneq7a"; + +#[derive(Clone, Debug, Default)] +pub struct DropboxConfig { + pub server_name: String, + pub client_id: String, + pub client_secret: String, + pub auth_json: String, +} + +impl super::LoginTrait for DropboxConfig { + fn get_sections( + window: &ApplicationWindow, + sender: Sender>, + ) -> (Vec, Button) { + let mut sections: Vec = vec![]; + let server_name = login_util::server_name_input(); + let submit_button = login_util::submit_button(); + + sections.push(server_name.clone()); + + submit_button.connect_clicked(glib::clone!(@weak window, @weak server_name => move |_| { + window.set_sensitive(false); + + let mut process = Command::new("rclone") + .args(["authorize", "dropbox", DEFAULT_CLIENT_ID, DEFAULT_CLIENT_SECRET]) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap(); + let kill_request = Rc::new(RefCell::new(false)); + + let dialog = MessageDialog::builder() + .title(&util::get_title!("Authentication to Dropbox")) + .heading("Authenticating to Dropbox...") + .body("Open the link that opened in your browser, and come back once you've finished.") + .build(); + dialog.add_response("cancel", "Cancel"); + dialog.connect_response(None, glib::clone!(@strong kill_request => move |dialog, resp| { + if resp != "cancel" { + return + } + + dialog.close(); + *kill_request.get_mut_ref() = true; + })); + dialog.show(); + + // Run until the process exits or the user clicks 'Cancel'. + loop { + // Sleep a little so the UI has a chance to process. + util::run_in_background(|| thread::sleep(Duration::from_millis(500))); + + // Check if the user clicked cancel. + if *kill_request.get_ref() { + window.set_sensitive(true); + return; + } + + // Otherwise if the command has finished, check if it returned a good exit code and then return it. + else if let Some(exit_status) = process.try_wait().unwrap() { + dialog.close(); + + if !exit_status.success() { + let mut stderr_string = String::new(); + process.stderr.take().unwrap().read_to_string(&mut stderr_string).unwrap(); + gtk_util::show_codeblock_error("Authentication Error", "There was an issue authenticating to Dropbox", &stderr_string); + window.set_sensitive(true); + break; + } else { + let mut stdout_string = String::new(); + process.stdout.take().unwrap().read_to_string(&mut stdout_string).unwrap(); + let auth_token = stdout_string.lines().nth(1).unwrap(); + + sender.send(Some(ServerType::Dropbox(DropboxConfig { + server_name: server_name.text().to_string(), + client_id: DEFAULT_CLIENT_ID.to_string(), + client_secret: DEFAULT_CLIENT_SECRET.to_string(), + auth_json: auth_token.to_string() + }))); + window.set_sensitive(true); + break; + } + } + } + })); + server_name.connect_changed(glib::clone!(@weak submit_button => move |server_name| login_util::check_responses(&[server_name], &submit_button))); + + (sections, submit_button) + } +} diff --git a/src/login/login_util.rs b/src/login/login_util.rs new file mode 100644 index 0000000..e9d9abc --- /dev/null +++ b/src/login/login_util.rs @@ -0,0 +1,127 @@ +//! A collection of helper functions for generating login UIs. +use crate::rclone::{self}; +use adw::{ + gtk::{Align, Button, Label}, + prelude::*, + EntryRow, PasswordEntryRow, +}; + +use url::Url; + +/// Get the input for the server name. +pub fn server_name_input() -> EntryRow { + let input = EntryRow::builder().title("Server Name").build(); + input.connect_changed(|input| { + let text = input.text(); + + // Get a list of already existing config names. + let existing_remotes: Vec = rclone::get_remotes() + .iter() + .map(|config| config.remote_name()) + .collect(); + + if existing_remotes.contains(&text.to_string()) { + input.add_css_class("error"); + input.set_tooltip_text(Some("Server name already exists.")); + } else { + input.remove_css_class("error"); + input.set_tooltip_text(None); + } + }); + + input +} + +/// Get the input for the server URL. +pub fn server_url_input() -> EntryRow { + let input = EntryRow::builder().title("Server URL").build(); + input.connect_changed(|input| { + let text = input.text(); + let url = Url::parse(&text); + + if let Err(err) = url { + let err_string = format!("Invalid server URL ({err})."); + input.add_css_class("error"); + input.set_tooltip_text(Some(&err_string)); + } else if !url.as_ref().unwrap().has_host() { + input.add_css_class("error"); + input.set_tooltip_text(Some("Invalid server URL (no domain specified).")); + } else if url.as_ref().unwrap().password().is_some() { + input.add_css_class("error"); + input.set_tooltip_text(Some("Invalid server URL (password was specified.")); + } else if !["http", "https"].contains(&url.as_ref().unwrap().scheme()) { + let err_string = format!( + "Invalid server URL(unknown server scheme {}).", + url.as_ref().unwrap().scheme() + ); + input.add_css_class("error"); + input.set_tooltip_text(Some(&err_string)); + } else { + input.remove_css_class("error"); + input.set_tooltip_text(None); + } + }); + input +} + +/// Get the input for usernames. +pub fn username_input() -> EntryRow { + let input = EntryRow::builder().title("Username").build(); + input.connect_changed(|input| { + let _text = input.text(); + + if input.text().contains(':') { + input.add_css_class("error"); + input.set_tooltip_text(Some("Username isn't allowed to contain ':'.")); + } else { + input.remove_css_class("error"); + input.set_tooltip_text(None); + } + }); + input +} + +/// Get the input for passwords. +pub fn password_input() -> PasswordEntryRow { + let input = PasswordEntryRow::builder().title("Password").build(); + input.connect_changed(|input| { + let _text = input.text(); + + if input.text().contains(':') { + input.add_css_class("error"); + input.set_tooltip_text(Some("Password isn't allowed to contain ':'.")); + } else { + input.remove_css_class("error"); + input.set_tooltip_text(None); + } + }); + input +} + +/// Get the login button. +pub fn submit_button() -> Button { + let label = Label::builder().label("Log in").build(); + let button = Button::builder() + .child(&label) + .halign(Align::End) + .margin_top(10) + .css_classes(vec!["login-window-submit-button".to_string()]) + .build(); + // Grey out the button initially so it can't be until items are validated. + button.set_sensitive(false); + button +} + +/// Grey out the password button if any of the specified fields have errors or +/// are empty. This ignores any entries that aren't sensitive. +pub fn check_responses(responses: &[&EntryRow], submit_button: &Button) { + let mut no_errors = true; + + for resp in responses { + if resp.is_sensitive() && (resp.has_css_class("error") || resp.text().is_empty()) { + no_errors = false; + } + } + + submit_button.set_sensitive(no_errors); +} diff --git a/src/login/mod.rs b/src/login/mod.rs new file mode 100644 index 0000000..7402c4e --- /dev/null +++ b/src/login/mod.rs @@ -0,0 +1,273 @@ +//! Functions and utilities for logging in to a server. +use crate::{ + entities::{RemotesActiveModel, RemotesModel}, + gtk_util, + mpsc::{self, Sender}, + rclone::{self}, + traits::*, + util, +}; +mod dropbox; +pub mod login_util; +mod nextcloud; +mod webdav; + +use adw::{ + glib, + gtk::{Box, Button, Inhibit, ListBox, Orientation, SelectionMode, StringList}, + prelude::*, + Application, ApplicationWindow, ComboRow, EntryRow, HeaderBar, +}; +use dropbox::DropboxConfig; +use nextcloud::NextcloudConfig; +use std::{cell::RefCell, rc::Rc}; +use webdav::WebDavConfig; + +use sea_orm::{entity::prelude::*, ActiveValue, DatabaseConnection}; +use serde_json::json; + +/// A trait to get some data from configs. +trait LoginTrait { + fn get_sections( + window: &ApplicationWindow, + sender: Sender>, + ) -> (Vec, Button); +} + +/// An enum representing valid storage types. +#[derive(Clone, Debug)] +pub enum ServerType { + Dropbox(dropbox::DropboxConfig), + Nextcloud(nextcloud::NextcloudConfig), + WebDav(webdav::WebDavConfig), +} + +impl ToString for ServerType { + fn to_string(&self) -> String { + match self { + Self::Dropbox(_) => "Dropbox", + Self::Nextcloud(_) => "Nextcloud", + Self::WebDav(_) => "WebDAV", + } + .to_string() + } +} + +// Verify if a specific config can log in to a server. +pub fn can_login(_app: &Application, config_name: &str) -> bool { + let res = librclone::rpc( + "operations/size", + json!({ + "fs": format!("{config_name}:"), + "remote": "/" + }) + .to_string(), + ); + + if let Err(err_str) = res { + let err: rclone::RcloneError = serde_json::from_str(&err_str).unwrap(); + let err_msg = if err.error.contains("Temporary failure in name resolution") { + "Unable to connect to the server. Check your internet connection and try again." + } else { + "Unable to authenticate to the server. Check your login credentials and try again." + }; + + gtk_util::show_error("Connection Error", "Unable to log in", Some(err_msg)); + false + } else { + true + } +} + +/// Create a new session. Returns [`Some`] with the new session if the client +/// succesfully logged in, and [`None`] on other events, such as closing the +/// window before logging in. Logged in clients can be obtained after this point +/// via [`rclone::get_configs`]. +pub fn login(app: &Application, db: &DatabaseConnection) -> Option { + // The mspc sender/reciever to get data from fields. + let (sender, mut reciever) = mpsc::channel::>(); + + // The window. + let window = ApplicationWindow::builder() + .application(app) + .title(&util::get_title!("Log in")) + .width_request(400) + .build(); + window.connect_close_request(glib::clone!(@strong sender => move |_| { + sender.send(None); + Inhibit(false) + })); + + // The stack containing the forms for all login sections. + let dropbox_name = ServerType::Dropbox(dropbox::DropboxConfig { + ..Default::default() + }) + .to_string(); + let nextcloud_name = ServerType::Nextcloud(nextcloud::NextcloudConfig { + ..Default::default() + }) + .to_string(); + let webdav_name = ServerType::WebDav(webdav::WebDavConfig { + ..Default::default() + }) + .to_string(); + + // The dropdown for selecting the server type. + let server_type_dropdown = ComboRow::builder().title("Server Type").build(); + let server_types_array = [ + dropbox_name.as_str(), + nextcloud_name.as_str(), + webdav_name.as_str(), + ]; + let server_types = StringList::new(&server_types_array); + server_type_dropdown.set_model(Some(&server_types)); + + // A box containing the header bar and input sections. + let container = Box::builder().orientation(Orientation::Vertical).build(); + let input_sections = ListBox::builder() + .selection_mode(SelectionMode::None) + .css_classes(vec!["boxed-list".to_string()]) + .build(); + container.append(&HeaderBar::new()); + container.append(&input_sections); + input_sections.append(&server_type_dropdown); + + // Set up the submit button. + let submit_button = login_util::submit_button(); + container.append(&submit_button); + + // Get the window items for each server type. + let dropbox_items = DropboxConfig::get_sections(&window, sender.clone()); + let nextcloud_items = NextcloudConfig::get_sections(&window, sender.clone()); + let webdav_items = WebDavConfig::get_sections(&window, sender); + + // Store the active items. + let active_items: Rc, Button)>> = + Rc::new(RefCell::new((vec![], submit_button))); + + // Configure the window to change the widgets when the selected server type + // changes. + server_type_dropdown.connect_selected_notify(glib::clone!(@weak container, @weak input_sections, @strong server_types, @strong nextcloud_items, @strong webdav_items, @strong active_items => move |server_type_dropdown| { + let server_type = server_types.string(server_type_dropdown.selected()).unwrap().to_string(); + + let (rows, submit_button) = match server_type.to_lowercase().as_str() { + "dropbox" => dropbox_items.clone(), + "nextcloud" => nextcloud_items.clone(), + "webdav" => webdav_items.clone(), + _ => unreachable!() + }; + + // Remove the current submit button. + let mut ptr = active_items.get_mut_ref(); + container.remove(&ptr.1); + + // Now remove the current listbox items. + for row in ptr.0.clone() { + // Reset the row to default styling and text so that when the user goes back it looks like a fresh page. + row.set_text(""); + row.remove_css_class("error"); + + // Actually remove the item. + input_sections.remove(&row); + ptr.0.remove(0); + } + + // Now set the ones for this remove. + for row in rows { + input_sections.append(&row); + ptr.0.push(row); + } + + // Now set the new submit button. + container.append(&submit_button); + ptr.1 = submit_button; + })); + // Go back and forth to the first widget so we can initialize our entries. + server_type_dropdown.set_selected(1); + server_type_dropdown.set_selected(0); + + // Set up the window and show it. + window.set_content(Some(&container)); + window.show(); + + // Keep receiving values from the windows on the stack until a valid config + // is found. + loop { + // If the user clicks the 'X' button on the window we get a [`None`] value. + let server = reciever.recv()?; + window.set_sensitive(false); + + // Create a new config with the requested name. + let config_name = match &server { + ServerType::Dropbox(config) => config.server_name.clone(), + ServerType::Nextcloud(config) => config.server_name.clone(), + ServerType::WebDav(config) => config.server_name.clone(), + }; + + let config_query = match &server { + ServerType::Dropbox(config) => json!({ + "name": config_name, + "parameters": { + "client_id": config.client_id, + "client_secret": config.client_secret, + "token": config.auth_json, + "config_refresh_token": false + }, + "type": "dropbox" + }), + ServerType::Nextcloud(config) => json!({ + "name": config_name, + "parameters": { + "url": config.server_url, + "vendor": "nextcloud", + "user": config.username, + "pass": config.password + }, + "type": "webdav", + "opt": { + "obscure": true + } + }), + ServerType::WebDav(config) => json!({ + "name": config_name, + "parameters": { + "url": config.server_url, + "vendor": "nextcloud", + "user": config.username, + "pass": config.password + }, + "type": "webdav", + "opt": { + "obscure": true + } + }), + }; + + util::run_in_background(move || { + librclone::rpc("config/create", config_query.to_string()).unwrap() + }); + + // If we can't connect to the server, assume invalid credentials were given, + // remote the config, and try asking for input again. + if !can_login(app, &config_name) { + util::run_in_background(move || { + librclone::rpc("config/delete", json!({ "name": config_name }).to_string()).unwrap() + }); + window.set_sensitive(true); + // We've passed validation otherwise, so add the remote to the db, close + // the window and return the config. + } else { + let model = util::await_future( + RemotesActiveModel { + name: ActiveValue::Set(config_name), + ..Default::default() + } + .insert(db), + ) + .unwrap(); + + window.close(); + return Some(model); + } + } +} diff --git a/src/login/nextcloud.rs b/src/login/nextcloud.rs new file mode 100644 index 0000000..652e24d --- /dev/null +++ b/src/login/nextcloud.rs @@ -0,0 +1,24 @@ +//! The data for a Nextcloud Rclone config. +use super::{ + webdav::{WebDavConfig, WebDavType}, + ServerType, +}; +use crate::mpsc::Sender; +use adw::{gtk::Button, ApplicationWindow, EntryRow}; + +#[derive(Clone, Debug, Default)] +pub struct NextcloudConfig { + pub server_name: String, + pub server_url: String, + pub username: String, + pub password: String, +} + +impl super::LoginTrait for NextcloudConfig { + fn get_sections( + _window: &ApplicationWindow, + sender: Sender>, + ) -> (Vec, Button) { + WebDavConfig::webdav_sections(sender, WebDavType::Nextcloud) + } +} diff --git a/src/login/webdav.rs b/src/login/webdav.rs new file mode 100644 index 0000000..b93b483 --- /dev/null +++ b/src/login/webdav.rs @@ -0,0 +1,77 @@ +//! The data for a WebDAV Rclone config. +use super::{login_util, nextcloud::NextcloudConfig, ServerType}; +use crate::mpsc::Sender; +use adw::{ + gtk::{glib, Button}, + prelude::*, + ApplicationWindow, EntryRow, +}; + +pub enum WebDavType { + Nextcloud, + WebDav, +} + +#[derive(Clone, Debug, Default)] +pub struct WebDavConfig { + pub server_name: String, + pub server_url: String, + pub username: String, + pub password: String, +} + +impl super::LoginTrait for WebDavConfig { + fn get_sections( + _window: &ApplicationWindow, + sender: Sender>, + ) -> (Vec, Button) { + Self::webdav_sections(sender, WebDavType::WebDav) + } +} + +impl WebDavConfig { + pub fn webdav_sections( + sender: Sender>, + webdav_type: WebDavType, + ) -> (Vec, Button) { + let mut sections: Vec = vec![]; + + let server_name = login_util::server_name_input(); + let server_url = login_util::server_url_input(); + let username = login_util::username_input(); + let password = login_util::password_input(); + let submit_button = login_util::submit_button(); + + sections.push(server_name.clone()); + sections.push(server_url.clone()); + sections.push(username.clone()); + sections.push(password.clone().into()); + + submit_button.connect_clicked( + glib::clone!(@weak server_name, @weak server_url, @weak username, @weak password => move |_| { + let server_type = match webdav_type { + WebDavType::Nextcloud => ServerType::Nextcloud(NextcloudConfig { + server_name: server_name.text().to_string(), + server_url: server_url.text().to_string(), + username: username.text().to_string(), + password: password.text().to_string(), + }), + WebDavType::WebDav => ServerType::WebDav(WebDavConfig{ + server_name: server_name.text().to_string(), + server_url: server_url.text().to_string(), + username: username.text().to_string(), + password: password.text().to_string(), + }) + }; + sender.send(Some(server_type)); + }), + ); + + server_name.connect_changed(glib::clone!(@weak server_name, @weak server_url, @weak username, @weak password, @weak submit_button => move |_| login_util::check_responses(&[&server_name, &server_url, &username, &password.into()], &submit_button))); + server_url.connect_changed(glib::clone!(@weak server_name, @weak server_url, @weak username, @weak password, @weak submit_button => move |_| login_util::check_responses(&[&server_name, &server_url, &username, &password.into()], &submit_button))); + username.connect_changed(glib::clone!(@weak server_name, @weak server_url, @weak username, @weak password, @weak submit_button => move |_| login_util::check_responses(&[&server_name, &server_url, &username, &password.into()], &submit_button))); + password.connect_changed(glib::clone!(@weak server_name, @weak server_url, @weak username, @weak password, @weak submit_button => move |_| login_util::check_responses(&[&server_name, &server_url, &username, &password.into()], &submit_button))); + + (sections, submit_button) + } +} diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..ee61bfd --- /dev/null +++ b/src/main.rs @@ -0,0 +1,205 @@ +#![feature(let_chains)] +#![feature(arc_unwrap_or_clone)] +#![feature(panic_info_message)] +#![feature(async_closure)] + +mod about; +mod entities; +mod gtk_util; +mod launch; +mod login; +mod migrations; +mod mpsc; +mod rclone; +mod traits; +mod util; + +use adw::{ + gtk::{self, gdk::Display, Align, Box, CssProvider, Label, Orientation, StyleContext}, + prelude::*, + Application, ApplicationWindow, HeaderBar, +}; +use clap::{Parser, Subcommand}; +use serde_json::json; +use std::{ + env, + fs::{self, File}, + io::{BufRead, BufReader}, + process::{Command, Stdio}, + thread, +}; + +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +struct Cli { + #[command(subcommand)] + command: Option, +} + +#[derive(Subcommand)] +enum Commands { + RunGui {}, +} + +fn main() { + // Initialize GTK. + gtk::init().unwrap(); + + // If we already have an instance running, don't create a new instance. Instead + // wait for the running instance to detect the file we create. + let notify_file = util::notify_open_file(); + if util::is_running_file().exists() { + if !notify_file.exists() && let Err(err) = File::create(¬ify_file) { + gtk_util::show_error( + "Notify Error", + &format!("Failed to notify the running Celeste instance that it needs to be opened [{err}]."), + None + ); + } + + return; + } + + // Configure Rclone. + let mut config = util::get_config_dir(); + config.push("rclone.conf"); + librclone::initialize(); + librclone::rpc("config/setpath", json!({ "path": config }).to_string()).unwrap(); + + // Load our CSS. + let provider = CssProvider::new(); + provider.load_from_data( + // This location maps to `/style.css` at the root of the repository. + include_bytes!("../style.css"), + ); + + StyleContext::add_provider_for_display( + &Display::default().unwrap(), + &provider, + gtk::STYLE_PROVIDER_PRIORITY_APPLICATION, + ); + + // Get the application. + let app = Application::builder().application_id(util::APP_ID).build(); + + // Due to GTK working in Rust via Rust's FFI, panics don't appear to be able to + // be captured (this hasn't been confirmed behavior, it's just what I've + // observed). Panics would like to be captured when they're encountered though, + // so we relaunch this program in a subprocess and capture any errors from + // there. + let cli = Cli::parse(); + if let Some(cmd) = cli.command { + match cmd { + Commands::RunGui {} => { + // Start up the application. + app.connect_activate(|app| { + launch::launch(app); + }); + + app.run_with_args::<&str>(&[]); + } + } + } else { + // Set `RUST_BACKTRACE` so we get a better backtrace for reporting. + env::set_var("RUST_BACKTRACE", "1"); + + // Run the command and get the stderr, checking for a backtrace. + let mut command = Command::new(env::args().next().unwrap()) + .arg("run-gui") + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .unwrap(); + let stdout_thread = thread::spawn(move || { + let mut stdout = String::new(); + let mut stdout_handle = command.stdout.as_mut().unwrap(); + let stdout_reader = BufReader::new(&mut stdout_handle); + + for line in stdout_reader.lines() { + let unwrapped_line = line.unwrap(); + println!("{unwrapped_line}"); + stdout.push_str(&unwrapped_line); + stdout.push('\n'); + } + + stdout + }); + let stderr_thread = thread::spawn(move || { + let mut stderr = String::new(); + let mut stderr_handle = command.stderr.as_mut().unwrap(); + let stderr_reader = BufReader::new(&mut stderr_handle); + + for line in stderr_reader.lines() { + let unwrapped_line = line.unwrap(); + eprintln!("{unwrapped_line}"); + stderr.push_str(&unwrapped_line); + stderr.push('\n'); + } + + stderr + }); + let _stdout = stdout_thread.join().unwrap(); + let stderr = stderr_thread.join().unwrap(); + + let backtrace = { + let mut backtrace = String::new(); + let mut backtrace_found = false; + + for line in stderr.lines() { + if backtrace_found && !line.contains("note: Some details are omitted") { + backtrace.push_str(line); + backtrace.push('\n'); + } else if line.starts_with("thread 'main' panicked at") { + backtrace.push_str(line); + backtrace.push('\n'); + backtrace_found = true; + } + } + + backtrace.pop(); // The extra newline at the end. + + if backtrace_found { + Some(backtrace) + } else { + None + } + }; + + // Show the backtrace in the GUI if one was found. + if backtrace.is_some() { + app.connect_startup(move |app| { + let window = ApplicationWindow::builder() + .application(app) + .title(&util::get_title!("Unknown Error")) + .build(); + let sections = Box::builder() + .orientation(Orientation::Vertical) + .build(); + sections.append(&HeaderBar::new()); + let error_label = Label::builder() + .label("Unknown Error") + .halign(Align::Start) + .build(); + sections.append(&error_label); + + let error_text = Label::builder() + .label("An unknown error has occurred while running. This is an internal issue with Celeste and should be reported.\n\nThe following backtrace may help with debugging the issue - note that it may contain information such as login tokens/keys, so avoid posting the information publically:") + .halign(Align::Start) + .build(); + sections.append(&error_text); + sections.append(>k_util::codeblock(backtrace.as_ref().unwrap())); + + window.set_content(Some(§ions)); + window.show(); + }); + + app.run_with_args::<&str>(&[]); + } + + // Delete the running lockfile if it got created. + let running_lock = util::is_running_file(); + if running_lock.exists() { + fs::remove_file(&running_lock).unwrap(); + } + } +} diff --git a/src/migrations/m20220101_000001_create_table.rs b/src/migrations/m20220101_000001_create_table.rs new file mode 100644 index 0000000..ff5aef0 --- /dev/null +++ b/src/migrations/m20220101_000001_create_table.rs @@ -0,0 +1,48 @@ +use sea_orm::{ConnectionTrait, Statement}; +use sea_orm_migration::prelude::*; + +#[derive(DeriveMigrationName)] +pub struct Migration; + +#[async_trait::async_trait] +impl MigrationTrait for Migration { + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + let sql = r#" + CREATE TABLE remotes ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + name TEXT NOT NULL + ); + + + CREATE TABLE sync_dirs ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + remote_id INTEGER NOT NULL, + local_path TEXT NOT NULL, + remote_path TEXT NOT NULL, + FOREIGN KEY(remote_id) REFERENCES remotes(id) + ); + + CREATE TABLE sync_items ( + id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, + sync_dir_id INTEGER NOT NULL, + local_path TEXT NOT NULL, + remote_path TEXT NOT NULL, + last_local_timestamp INTEGER NOT NULL, + last_remote_timestamp INTEGER NOT NULL, + FOREIGN KEY(sync_dir_id) REFERENCES sync_dirs(id) + ); + "#; + let stmt = Statement::from_string(manager.get_database_backend(), sql.to_owned()); + manager.get_connection().execute(stmt).await.map(|_| ()) + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + let sql = " + DROP TABLE `sync_items`; + DROP TABLE `sync_dirs`; + DROP TABLE `remotes`; + "; + let stmt = Statement::from_string(manager.get_database_backend(), sql.to_owned()); + manager.get_connection().execute(stmt).await.map(|_| ()) + } +} diff --git a/src/migrations/mod.rs b/src/migrations/mod.rs new file mode 100644 index 0000000..2c605af --- /dev/null +++ b/src/migrations/mod.rs @@ -0,0 +1,12 @@ +pub use sea_orm_migration::prelude::*; + +mod m20220101_000001_create_table; + +pub struct Migrator; + +#[async_trait::async_trait] +impl MigratorTrait for Migrator { + fn migrations() -> Vec> { + vec![Box::new(m20220101_000001_create_table::Migration)] + } +} diff --git a/src/mpsc.rs b/src/mpsc.rs new file mode 100644 index 0000000..7d218f9 --- /dev/null +++ b/src/mpsc.rs @@ -0,0 +1,48 @@ +use adw::gtk::glib::MainContext; +use std::fmt::Debug; +use tokio::sync::mpsc::{self as tokio_mpsc, Receiver as TokioReceiver, Sender as TokioSender}; + +/// Sends values to the associated [`Receiver`]. +#[derive(Clone)] +pub struct Sender { + sender: TokioSender, +} + +impl Sender { + /// Send a value to the [`Receiver`]. This function does nothing if the + /// [`Receiver`] has already closed up their connections. + pub fn send(&self, item: T) { + MainContext::default() + .block_on(self.sender.send(item)) + .unwrap_or(()); + } +} + +/// Receives values from the associated [`Sender`]. +pub struct Receiver { + receiver: TokioReceiver, +} + +impl Receiver { + /// Receive the value from the [`Sender`]. + pub fn recv(&mut self) -> T { + let item = MainContext::default() + .block_on(self.receiver.recv()) + .unwrap(); + item + } +} + +/// Return a tuple containing a [`Sender`] and [`Receiver`] that can be used to +/// send messages across a GTK application. +pub fn channel() -> (Sender, Receiver) { + let (tokio_sender, tokio_receiver) = tokio_mpsc::channel(1); + ( + Sender { + sender: tokio_sender, + }, + Receiver { + receiver: tokio_receiver, + }, + ) +} diff --git a/src/rclone.rs b/src/rclone.rs new file mode 100644 index 0000000..fd0f0ea --- /dev/null +++ b/src/rclone.rs @@ -0,0 +1,329 @@ +//! Structs and functions for use with Rclone RPC calls. +use crate::util; +use adw::glib; +use serde::Deserialize; +use serde_json::json; +use std::collections::HashMap; +use time::OffsetDateTime; + +/// Get a remote from the config file. +pub fn get_remote(remote: T) -> Option { + let remote = remote.to_string(); + + let config_str = util::run_in_background( + glib::clone!(@strong remote => move || librclone::rpc("config/get", json!({ + "name": remote + }).to_string()).unwrap()), + ); + let config: HashMap = serde_json::from_str(&config_str).unwrap(); + + match config["type"].as_str() { + "dropbox" => Some(Remote::Dropbox(DropboxRemote { + remote_name: remote, + client_id: config["client_id"].clone(), + client_secret: config["client_secret"].clone(), + })), + "webdav" => { + let vendor = match config["vendor"].as_str() { + "nextcloud" => WebDavVendors::Nextcloud, + "webdav" => WebDavVendors::WebDav, + _ => unreachable!(), + }; + + Some(Remote::WebDav(WebDavRemote { + remote_name: remote, + user: config["user"].clone(), + pass: config["pass"].clone(), + url: config["user"].clone(), + vendor, + })) + } + _ => None, + } +} + +/// Get all the remotes from the config file. +pub fn get_remotes() -> Vec { + let configs_str = util::run_in_background(move || { + librclone::rpc("config/listremotes", json!({}).to_string()) + .unwrap_or_else(|_| unreachable!()) + }); + let configs = { + let config: HashMap> = serde_json::from_str(&configs_str).unwrap(); + config.get(&"remotes".to_string()).unwrap().to_owned() + }; + let mut celeste_configs = vec![]; + + for config in configs { + celeste_configs.push(get_remote(&config).unwrap()); + } + + celeste_configs +} + +/// The types of remotes in the config. +#[derive(Clone)] +pub enum Remote { + Dropbox(DropboxRemote), + WebDav(WebDavRemote), +} + +impl Remote { + pub fn remote_name(&self) -> String { + match self { + Remote::Dropbox(remote) => remote.remote_name.clone(), + Remote::WebDav(remote) => remote.remote_name.clone(), + } + } +} + +// The Dropbox remote type. +#[derive(Clone, Debug)] +pub struct DropboxRemote { + /// The name of the remote. + pub remote_name: String, + /// The client id. + pub client_id: String, + /// The client secret. + pub client_secret: String, +} + +// The WebDav remote type. +#[derive(Clone, Debug)] +pub struct WebDavRemote { + /// The name of the remote. + pub remote_name: String, + /// The username for the remote. + pub user: String, + /// The password for the remote. + pub pass: String, + /// The URL for the remote. + pub url: String, + /// The vendor of the remote. + pub vendor: WebDavVendors, +} + +/// Possible WebDav vendors. +#[derive(Clone, Debug)] +pub enum WebDavVendors { + Nextcloud, + WebDav, +} + +impl ToString for WebDavVendors { + fn to_string(&self) -> String { + match self { + Self::Nextcloud => "Nextcloud", + Self::WebDav => "WebDav", + } + .to_string() + } +} + +/// Error returned from Rclone. +#[derive(Clone, Deserialize, Debug)] +pub struct RcloneError { + pub error: String, +} + +/// The output of an `operations/stat` command. +#[derive(Clone, Deserialize, Debug)] +pub struct RcloneStat { + item: Option, +} + +/// The output of an `operations/list` command. +#[derive(Clone, Deserialize, Debug)] +pub struct RcloneList { + #[serde(rename = "list")] + list: Vec, +} + +/// The list of items in a folder, from the `list` object in the output of the +/// `operations/list` command. +#[derive(Clone, Deserialize, Debug)] +pub struct RcloneRemoteItem { + #[serde(rename = "IsDir")] + pub is_dir: bool, + #[serde(rename = "Path")] + pub path: String, + #[serde(rename = "Name")] + pub name: String, + #[serde(rename = "ModTime", with = "time::serde::rfc3339")] + pub mod_time: OffsetDateTime, +} + +/// The types of items to show in an `operations/list` command. +#[derive(Clone, Debug)] +pub enum RcloneListFilter { + /// Return all items. + All, + /// Only return directories. + Dirs, + /// Only return files. + #[allow(dead_code)] + Files, +} + +/// Functions for syncing to a remote. +/// All of these functions run long-running tasks under +/// [`util::run_in_background`], so it's safe to run these under the GUI. +pub mod sync { + use super::{RcloneError, RcloneList, RcloneListFilter, RcloneRemoteItem, RcloneStat}; + use crate::util; + use serde_json::json; + + /// Get a remote name. + fn get_remote_name(remote: &str) -> String { + if remote.ends_with(':') { + panic!("Remote '{remote}' is not allowed to end with a ':'. Please omit it.",); + } + format!("{remote}:") + } + + /// Run an Rclone command without blocking the GUI. + fn run(method: T, input: T) -> Result { + let method = method.to_string(); + let input = input.to_string(); + util::run_in_background(|| librclone::rpc(method, input)) + } + + /// Common function for some of the below command. + fn common(command: &str, remote_name: &str, path: &str) -> Result<(), RcloneError> { + let resp = run( + command, + &json!({ + "fs": get_remote_name(remote_name), + "remote": util::strip_slashes(path), + }) + .to_string(), + ); + + match resp { + Ok(_) => Ok(()), + Err(json_str) => Err(serde_json::from_str(&json_str).unwrap()), + } + } + + /// Delete a config. + pub fn delete_config(remote_name: &str) -> Result<(), RcloneError> { + let resp = run("config/delete", &json!({ "name": remote_name }).to_string()); + + match resp { + Ok(_) => Ok(()), + Err(json_str) => Err(serde_json::from_str(&json_str).unwrap()), + } + } + + /// Get statistics about a file or folder. + pub fn stat(remote_name: &str, path: &str) -> Result, RcloneError> { + let resp = run( + "operations/stat", + &json!({ + "fs": get_remote_name(remote_name), + "remote": util::strip_slashes(path) + }) + .to_string(), + ); + + match resp { + Ok(json_str) => Ok(serde_json::from_str::(&json_str).unwrap().item), + Err(json_str) => Err(serde_json::from_str(&json_str).unwrap()), + } + } + + /// List the files/folders in a path. + pub fn list( + remote_name: &str, + path: &str, + recursive: bool, + filter: RcloneListFilter, + ) -> Result, RcloneError> { + let opts = match filter { + RcloneListFilter::All => json!({ "recurse": recursive }), + RcloneListFilter::Dirs => json!({"dirsOnly": true, "recurse": recursive}), + RcloneListFilter::Files => json!({"filesOnly": true, "recurse": recursive}), + }; + + let resp = run( + "operations/list", + &json!({ + "fs": get_remote_name(remote_name), + "remote": util::strip_slashes(path), + "opt": opts + }) + .to_string(), + ); + + match resp { + Ok(json_str) => Ok(serde_json::from_str::(&json_str).unwrap().list), + Err(json_str) => Err(serde_json::from_str(&json_str).unwrap()), + } + } + + /// make a directory on the remote. + pub fn mkdir(remote_name: &str, path: &str) -> Result<(), RcloneError> { + common("operations/mkdir", remote_name, path) + } + + /// Delete a file. + pub fn delete(remote_name: &str, path: &str) -> Result<(), RcloneError> { + common("operations/delete", remote_name, path) + } + /// Remove a directory and all of its contents. + pub fn purge(remote_name: &str, path: &str) -> Result<(), RcloneError> { + common("operations/purge", remote_name, path) + } + + /// Utility for copy functions. + fn copy( + src_fs: &str, + src_remote: &str, + dst_fs: &str, + dst_remote: &str, + ) -> Result<(), RcloneError> { + let resp = run( + "operations/copyfile", + &json!({ + "srcFs": src_fs, + "srcRemote": util::strip_slashes(src_remote), + "dstFs": dst_fs, + "dstRemote": util::strip_slashes(dst_remote) + }) + .to_string(), + ); + + match resp { + Ok(_) => Ok(()), + Err(json_str) => Err(serde_json::from_str(&json_str).unwrap()), + } + } + + /// Copy a file from the local machine to the remote. + pub fn copy_to_remote( + local_file: &str, + remote_name: &str, + remote_destination: &str, + ) -> Result<(), RcloneError> { + copy( + "/", + local_file, + &get_remote_name(remote_name), + remote_destination, + ) + } + + /// Copy a file from the remote to the local machine. + pub fn copy_to_local( + local_destination: &str, + remote_name: &str, + remote_file: &str, + ) -> Result<(), RcloneError> { + copy( + &get_remote_name(remote_name), + remote_file, + "/", + local_destination, + ) + } +} diff --git a/src/traits.rs b/src/traits.rs new file mode 100644 index 0000000..8ceb3ee --- /dev/null +++ b/src/traits.rs @@ -0,0 +1,37 @@ +use std::cell::{Ref, RefCell, RefMut}; + +pub mod prelude { + pub use super::{GetRcRef, GetRcRefMut}; +} + +/// A trait to get the [`Ref`] out of a [`RefCell`], waiting until it can be +/// obtained. +pub trait GetRcRef { + fn get_ref(&self) -> Ref<'_, T>; +} + +impl GetRcRef for RefCell { + fn get_ref(&self) -> Ref<'_, T> { + loop { + if let Ok(reference) = self.try_borrow() { + return reference; + } + } + } +} + +/// A trait to get the [`RefMut`] out of a [`RefCell`], waiting until it can be +/// obtained. +pub trait GetRcRefMut { + fn get_mut_ref(&self) -> RefMut<'_, T>; +} + +impl GetRcRefMut for RefCell { + fn get_mut_ref(&self) -> RefMut<'_, T> { + loop { + if let Ok(reference) = self.try_borrow_mut() { + return reference; + } + } + } +} diff --git a/src/util.rs b/src/util.rs new file mode 100644 index 0000000..10d5231 --- /dev/null +++ b/src/util.rs @@ -0,0 +1,70 @@ +use adw::glib::{self, MainContext}; + +use futures::future::Future; +use std::path::PathBuf; + +pub static APP_ID: &str = "com.hunterwittenborn.Celeste"; + +/// Get the value out of a future. +pub fn await_future(future: F) -> F::Output { + futures::executor::block_on(future) +} + +/// Run a closure in the background so that the UI can keep running. +pub fn run_in_background T + Send + 'static>(f: F) -> T { + MainContext::default().block_on(blocking::unblock(f)) +} + +/// Format a directory with the user's home directory replaced with '~'. +pub fn fmt_home(dir: &str) -> String { + let home_dir = glib::home_dir().into_os_string().into_string().unwrap(); + + match dir.strip_prefix(&home_dir) { + Some(string) => "~".to_string() + string, + None => dir.to_string(), + } +} + +/// Get the user's config directory. +pub fn get_config_dir() -> PathBuf { + let mut config_dir = glib::user_config_dir(); + config_dir.push("celeste"); + config_dir +} + +/// Get the lockfile that's used to check if a Celeste instance is running. +pub fn is_running_file() -> PathBuf { + let mut dir = glib::user_config_dir(); + dir.push("celeste"); + dir.push("running.lock"); + dir +} + +/// Get the file that's used to open a running Celeste instance. +pub fn notify_open_file() -> PathBuf { + let mut dir = glib::user_config_dir(); + dir.push("celeste"); + dir.push("notify.lock"); + dir +} + +/// Strip the slashes from the beginning and end of a string. +pub fn strip_slashes(string: &str) -> String { + let stripped_prefix = match string.strip_prefix('/') { + Some(string) => string.to_string(), + None => string.to_string(), + }; + + match stripped_prefix.strip_suffix('/') { + Some(string) => string.to_string(), + None => stripped_prefix, + } +} + +/// Macro to get the title of a window. +macro_rules! get_title { + ($($arg:tt)*) => { + format!($($arg)*) + " - Celeste" + } +} +pub(crate) use get_title;