diff --git a/Cargo.lock b/Cargo.lock index 9275487..a434d6a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78d1833b3838dbe990df0f1f87baf640cf6146e898166afe401839d1b001e570" dependencies = [ - "bitflags", + "bitflags 1.2.1", "bytes 0.5.6", "futures-core", "futures-sink", @@ -27,7 +27,7 @@ dependencies = [ "actix-service", "actix-utils", "derive_more", - "either", + "either 1.6.1", "futures-util", "http", "log", @@ -43,7 +43,7 @@ checksum = "d031468a7859f71674e5531bd05137e0ea5de05ec9a917314330b88c582e2e0a" dependencies = [ "actix-service", "actix-web", - "bitflags", + "bitflags 1.2.1", "bytes 0.5.6", "derive_more", "futures-core", @@ -68,13 +68,13 @@ dependencies = [ "actix-threadpool", "actix-utils", "base64 0.13.0", - "bitflags", + "bitflags 1.2.1", "brotli2", "bytes 0.5.6", "cookie", "copyless", "derive_more", - "either", + "either 1.6.1", "encoding_rs", "flate2", "futures-channel", @@ -220,9 +220,9 @@ dependencies = [ "actix-codec", "actix-rt", "actix-service", - "bitflags", + "bitflags 1.2.1", "bytes 0.5.6", - "either", + "either 1.6.1", "futures-channel", "futures-sink", "futures-util", @@ -276,7 +276,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -345,7 +345,7 @@ version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8d3a45e77e34375a7923b1e8febb049bb011f064714a8e17a1a616fef01da13d" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -380,6 +380,21 @@ dependencies = [ "serde_urlencoded", ] +[[package]] +name = "backtrace" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "150ae7828afa7afb6d474f909d64072d21de1f3365b6e8ad8029bf7b1c6350a0" +dependencies = [ + "backtrace-sys", + "cfg-if 0.1.10", + "dbghelp-sys", + "debug-builders", + "kernel32-sys", + "libc", + "winapi 0.2.8", +] + [[package]] name = "backtrace" version = "0.3.55" @@ -394,6 +409,16 @@ dependencies = [ "rustc-demangle", ] +[[package]] +name = "backtrace-sys" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18fbebbe1c9d1f383a9cc7e8ccdb471b91c8d024ee9c2ca5b5346121fe8b4399" +dependencies = [ + "cc", + "libc", +] + [[package]] name = "base-x" version = "0.2.8" @@ -412,6 +437,12 @@ version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" +[[package]] +name = "bitflags" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aad18937a628ec6abcd26d1489012cc0e18c21798210f491af69ded9b881106d" + [[package]] name = "bitflags" version = "1.2.1" @@ -551,6 +582,18 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "chomp" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f74ad218e66339b11fd23f693fb8f1d621e80ba6ac218297be26073365d163d" +dependencies = [ + "bitflags 0.7.0", + "conv", + "debugtrace", + "either 0.1.7", +] + [[package]] name = "chrono" version = "0.4.19" @@ -582,6 +625,15 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" +[[package]] +name = "conv" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ff10625fd0ac447827aa30ea8b861fead473bb60aeb73af6c1c58caf0d1299" +dependencies = [ + "custom_derive", +] + [[package]] name = "cookie" version = "0.14.3" @@ -691,6 +743,37 @@ dependencies = [ "subtle", ] +[[package]] +name = "custom_derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef8ae57c4978a2acd8b869ce6b9ca1dfe817bff704c220209fdef2c0b75a01b9" + +[[package]] +name = "dbghelp-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97590ba53bcb8ac28279161ca943a924d1fd4a8fb3fa63302591647c4fc5b850" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "debug-builders" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f5d8e3d14cabcb2a8a59d7147289173c6ada77a0bc526f6b85078f941c0cf12" + +[[package]] +name = "debugtrace" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62e432bd83c5d70317f6ebd8a50ed4afb32907c64d6e2e1e65e339b06dc553f3" +dependencies = [ + "backtrace 0.1.8", +] + [[package]] name = "deflate" version = "0.8.6" @@ -707,7 +790,7 @@ version = "0.99.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41cb0e6161ad61ed084a36ba71fbba9e3ac5aee3606fb607fe08da6acbcf3d8c" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -730,7 +813,7 @@ version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -769,6 +852,12 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" +[[package]] +name = "either" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a39bffec1e2015c5d8a6773cb0cf48d0d758c842398f624c34969071f5499ea7" + [[package]] name = "either" version = "1.6.1" @@ -855,7 +944,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c5f0096a91d210159eceb2ff5e1c4da18388a170e1e3ce948aac9c8fdbbf595" dependencies = [ "heck", - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -869,6 +958,28 @@ dependencies = [ "version_check 0.9.2", ] +[[package]] +name = "failure" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d32e9bd16cc02eae7db7ef620b392808b89f6a5e16bb3497d159c6b92a0f4f86" +dependencies = [ + "backtrace 0.3.55", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa4da3c766cd7a0db8242e326e9e4e081edd567072893ed320008189715366a4" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.54", + "synstructure", +] + [[package]] name = "fake-simd" version = "0.1.2" @@ -909,7 +1020,7 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" dependencies = [ - "bitflags", + "bitflags 1.2.1", "fuchsia-zircon-sys", ] @@ -961,8 +1072,8 @@ version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "77408a692f1f97bcc61dc001d752e00643408fbc922e4d634c655df50d595556" dependencies = [ - "proc-macro-hack", - "proc-macro2", + "proc-macro-hack 0.5.19", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -997,7 +1108,7 @@ dependencies = [ "memchr", "pin-project 1.0.2", "pin-utils", - "proc-macro-hack", + "proc-macro-hack 0.5.19", "proc-macro-nested", "slab", ] @@ -1077,6 +1188,44 @@ version = "0.23.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6503fe142514ca4799d4c26297c4248239fe8838d827db6bd6065c6ed29a6ce" +[[package]] +name = "guid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e691c64d9b226c7597e29aeb46be753beb8c9eeef96d8c78dfd4d306338a38da" +dependencies = [ + "chomp", + "failure", + "failure_derive", + "guid-macro-impl", + "guid-parser", + "proc-macro-hack 0.4.2", + "winapi 0.2.8", +] + +[[package]] +name = "guid-macro-impl" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d50f7c496073b5a5dec0f6f1c149113a50960ce25dd2a559987a5a71190816" +dependencies = [ + "chomp", + "guid-parser", + "proc-macro-hack 0.4.2", + "quote 0.4.2", + "syn 0.12.15", +] + +[[package]] +name = "guid-parser" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc7adb441828023999e6cff9eb1ea63156f7ec37ab5bf690005e8fc6c1148ad" +dependencies = [ + "chomp", + "winapi 0.2.8", +] + [[package]] name = "h2" version = "0.2.7" @@ -1110,7 +1259,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ed18eb2459bf1a09ad2d6b1547840c3e5e62882fa09b9a6a20b1de8e3228848f" dependencies = [ "base64 0.12.3", - "bitflags", + "bitflags 1.2.1", "bytes 0.5.6", "headers-core", "http", @@ -1206,7 +1355,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "02c11bb50ce1568516aefbe4b6564c3feaf15a8e5ccbea90fa652012446ae9bf" dependencies = [ - "bitflags", + "bitflags 1.2.1", "byteorder", "encoding", "flate2", @@ -1448,7 +1597,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9753f12909fd8d923f75ae5c3258cae1ed3c8ec052e1b38c93c21a6d157f789c" dependencies = [ "migrations_internals", - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -1642,6 +1791,16 @@ dependencies = [ "byteorder", ] +[[package]] +name = "ole32-sys" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d2c49021782e5233cd243168edfa8037574afed4eba4bbaf538b3d8d1789d8c" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "once_cell" version = "1.5.2" @@ -1748,7 +1907,7 @@ version = "0.4.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "65ad2ae56b6abe3a1ee25f15ee605bacadb9a764edaba9c2bf4103800d4a1895" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -1759,7 +1918,7 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8e8d2bf0b23038a4424865103a4df472855692821aab4e4f5c3312d461d9e5f" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -1794,7 +1953,7 @@ version = "0.16.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970" dependencies = [ - "bitflags", + "bitflags 1.2.1", "crc32fast", "deflate", "miniz_oxide 0.3.7", @@ -1848,6 +2007,7 @@ dependencies = [ "url", "uuid", "winapi 0.3.9", + "winfolder", ] [[package]] @@ -1856,18 +2016,42 @@ version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" +[[package]] +name = "proc-macro-hack" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "463bf29e7f11344e58c9e01f171470ab15c925c6822ad75028cc1c0e1d1eb63b" +dependencies = [ + "proc-macro-hack-impl", +] + [[package]] name = "proc-macro-hack" version = "0.5.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" +[[package]] +name = "proc-macro-hack-impl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c47dcb1594802de8c02f3b899e2018c78291168a22c281be21ea0fb4796842" + [[package]] name = "proc-macro-nested" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eba180dafb9038b050a4c280019bbedf9f2467b61e5d892dcad585bb57aadc5a" +[[package]] +name = "proc-macro2" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd07deb3c6d1d9ff827999c7f9b04cdfd66b1b17ae508e14fe47b620f2282ae0" +dependencies = [ + "unicode-xid 0.1.0", +] + [[package]] name = "proc-macro2" version = "1.0.24" @@ -1911,13 +2095,22 @@ version = "0.3.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" +[[package]] +name = "quote" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1eca14c727ad12702eb4b6bfb5a232287dcf8385cb8ca83a3eeaf6519c44c408" +dependencies = [ + "proc-macro2 0.2.3", +] + [[package]] name = "quote" version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", ] [[package]] @@ -1980,7 +2173,7 @@ checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" dependencies = [ "autocfg", "crossbeam-deque", - "either", + "either 1.6.1", "rayon-core", ] @@ -2154,7 +2347,7 @@ version = "1.0.118" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c84d3526699cd55261af4b941e4e725444df67aa4f9e6a3564f18030d12672df" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -2226,6 +2419,16 @@ dependencies = [ "opaque-debug 0.3.0", ] +[[package]] +name = "shell32-sys" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ee04b46101f57121c9da2b151988283b6beb79b34f5bb29a58ee48cb695122c" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + [[package]] name = "signal-hook-registry" version = "1.2.2" @@ -2305,7 +2508,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "serde", "serde_derive", @@ -2319,7 +2522,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" dependencies = [ "base-x", - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "serde", "serde_derive", @@ -2351,13 +2554,24 @@ dependencies = [ "unicode-xid 0.0.4", ] +[[package]] +name = "syn" +version = "0.12.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c97c05b8ebc34ddd6b967994d5c6e9852fa92f8b82b3858c39451f97346dcce5" +dependencies = [ + "proc-macro2 0.2.3", + "quote 0.4.2", + "unicode-xid 0.1.0", +] + [[package]] name = "syn" version = "1.0.54" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a2af957a63d6bd42255c359c93d9bfdb97076bd3b820897ce55ffbfbf107f44" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "unicode-xid 0.2.1", ] @@ -2371,6 +2585,18 @@ dependencies = [ "unicode-xid 0.0.4", ] +[[package]] +name = "synstructure" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b834f2d66f734cb897113e34aaff2f1ab4719ca946f9a7358dba8f8064148701" +dependencies = [ + "proc-macro2 1.0.24", + "quote 1.0.7", + "syn 1.0.54", + "unicode-xid 0.2.1", +] + [[package]] name = "termcolor" version = "1.1.2" @@ -2395,7 +2621,7 @@ version = "1.0.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -2450,7 +2676,7 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" dependencies = [ - "proc-macro-hack", + "proc-macro-hack 0.5.19", "time-macros-impl", ] @@ -2460,8 +2686,8 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e5c3be1edfad6027c69f5491cf4cb310d1a71ecd6af742788c6ff8bced86b8fa" dependencies = [ - "proc-macro-hack", - "proc-macro2", + "proc-macro-hack 0.5.19", + "proc-macro2 1.0.24", "quote 1.0.7", "standback", "syn 1.0.54", @@ -2569,7 +2795,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "53861fcb288a166aae4c508ae558ed18b53838db728d4d310aad08270a7d4c2b" dependencies = [ "async-trait", - "backtrace", + "backtrace 0.3.55", "enum-as-inner", "futures", "idna", @@ -2588,7 +2814,7 @@ version = "0.19.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6759e8efc40465547b0dfce9500d733c65f969a4cbbfbe3ccf68daaa46ef179e" dependencies = [ - "backtrace", + "backtrace 0.3.55", "cfg-if 0.1.10", "futures", "ipconfig", @@ -2653,6 +2879,12 @@ version = "0.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" +[[package]] +name = "unicode-xid" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc72304796d0818e357ead4e000d19c9c174ab23dc11093ac919054d20a6a7fc" + [[package]] name = "unicode-xid" version = "0.2.1" @@ -2728,7 +2960,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c860ad1273f4eee7006cee05db20c9e60e5d24cba024a32e1094aa8e574f3668" dependencies = [ "nom", - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", ] @@ -2792,7 +3024,7 @@ dependencies = [ "bumpalo", "lazy_static", "log", - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", "wasm-bindgen-shared", @@ -2814,7 +3046,7 @@ version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5a48c72f299d80557c7c62e37e7225369ecc0c963964059509fbafe917c7549" dependencies = [ - "proc-macro2", + "proc-macro2 1.0.24", "quote 1.0.7", "syn 1.0.54", "wasm-bindgen-backend", @@ -2911,6 +3143,18 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winfolder" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b137073183b238dc0e56dd4d77d2fc18abc6ebed8bbf4bbdb355c0f70efa3982" +dependencies = [ + "guid", + "ole32-sys", + "shell32-sys", + "winapi 0.2.8", +] + [[package]] name = "winreg" version = "0.6.2" diff --git a/Cargo.toml b/Cargo.toml index 3389112..20601d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,6 +61,7 @@ features = ["bmp", "gif", "jpeg", "png"] [target.'cfg(windows)'.dependencies] uuid = { version="0.8", optional = true } winapi = { version = "0.3.3", features = ["winuser", "libloaderapi", "shellapi", "errhandlingapi"], optional = true } +winfolder = { version = "0.1.1" } [target.'cfg(unix)'.dependencies] sd-notify = "0.1.0" diff --git a/res/windows/release_script.ps1 b/res/windows/release_script.ps1 index 2bab312..b041079 100644 --- a/res/windows/release_script.ps1 +++ b/res/windows/release_script.ps1 @@ -8,13 +8,15 @@ $rc_exe = Join-Path "C:\Program Files (x86)\Windows Kits\10\bin\10.0.18362.0\x64 "" "Compiling executable" -$script:INSTALL_DIR = "$env:LOCALAPPDATA\Permafrost\Polaris" -$env:POLARIS_WEB_DIR = "$INSTALL_DIR\web" -$env:POLARIS_SWAGGER_DIR = "$INSTALL_DIR\swagger" -$env:POLARIS_DB_DIR = "$INSTALL_DIR" -$env:POLARIS_LOG_DIR = "$INSTALL_DIR" -$env:POLARIS_CACHE_DIR = "$INSTALL_DIR" -$env:POLARIS_PID_DIR = "$INSTALL_DIR" +# TODO: Uncomment the following once Polaris can do variable expansion of %LOCALAPPDATA% +# And remove the code setting these as defaults in `service/mod.rs` +# $script:INSTALL_DIR = "%LOCALAPPDATA%\Permafrost\Polaris" +# $env:POLARIS_WEB_DIR = "$INSTALL_DIR\web" +# $env:POLARIS_SWAGGER_DIR = "$INSTALL_DIR\swagger" +# $env:POLARIS_DB_DIR = "$INSTALL_DIR" +# $env:POLARIS_LOG_DIR = "$INSTALL_DIR" +# $env:POLARIS_CACHE_DIR = "$INSTALL_DIR" +# $env:POLARIS_PID_DIR = "$INSTALL_DIR" cargo rustc --release --features "ui" -- -C link-args="/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup res\windows\application\application.res" cargo rustc --release -- -o ".\target\release\polaris-cli.exe" -C link-args="res\windows\application\application.res" diff --git a/src/service/mod.rs b/src/service/mod.rs index f5ea083..c97fc85 100644 --- a/src/service/mod.rs +++ b/src/service/mod.rs @@ -34,6 +34,62 @@ pub struct Context { pub vfs_manager: vfs::Manager, } +struct Paths { + db_dir_path: PathBuf, + web_dir_path: PathBuf, + swagger_dir_path: PathBuf, + cache_dir_path: PathBuf, +} + +// TODO Make this the only implementation when we can expand %LOCALAPPDATA% correctly on Windows +// And fix the installer accordingly (`release_script.ps1`) +#[cfg(not(windows))] +impl Default for Paths { + fn default() -> Self { + Self { + db_dir_path: ["."].iter().collect(), + web_dir_path: [".", "web"].iter().collect(), + swagger_dir_path: [".", "docs", "swagger"].iter().collect(), + cache_dir_path: ["."].iter().collect(), + } + } +} + +#[cfg(windows)] +impl Default for Paths { + fn default() -> Self { + let local_app_data = winfolder::Folder::LocalAppData.path(); + let install_directory: PathBuf = + local_app_data.join(["Permafrost", "Polaris"].iter().collect::<PathBuf>()); + Self { + db_dir_path: install_directory.clone(), + web_dir_path: install_directory.join("web"), + swagger_dir_path: install_directory.join("swagger"), + cache_dir_path: install_directory.clone(), + } + } +} + +impl Paths { + fn new() -> Self { + let defaults = Self::default(); + Self { + db_dir_path: option_env!("POLARIS_DB_DIR") + .map(PathBuf::from) + .unwrap_or(defaults.db_dir_path), + web_dir_path: option_env!("POLARIS_WEB_DIR") + .map(PathBuf::from) + .unwrap_or(defaults.web_dir_path), + swagger_dir_path: option_env!("POLARIS_SWAGGER_DIR") + .map(PathBuf::from) + .unwrap_or(defaults.swagger_dir_path), + cache_dir_path: option_env!("POLARIS_CACHE_DIR") + .map(PathBuf::from) + .unwrap_or(defaults.cache_dir_path), + } + } +} + pub struct ContextBuilder { port: Option<u16>, config_file_path: Option<PathBuf>, @@ -56,31 +112,24 @@ impl ContextBuilder { } pub fn build(self) -> anyhow::Result<Context> { - let db_path = self.database_file_path.unwrap_or_else(|| { - let mut path = PathBuf::from(option_env!("POLARIS_DB_DIR").unwrap_or(".")); - path.push("db.sqlite"); - path - }); + let paths = Paths::new(); + + let db_path = self + .database_file_path + .unwrap_or(paths.db_dir_path.join("db.sqlite")); fs::create_dir_all(&db_path.parent().unwrap())?; let db = DB::new(&db_path)?; - let web_dir_path = self - .web_dir_path - .or(option_env!("POLARIS_WEB_DIR").map(PathBuf::from)) - .unwrap_or([".", "web"].iter().collect()); + let web_dir_path = self.web_dir_path.unwrap_or(paths.web_dir_path); fs::create_dir_all(&web_dir_path)?; - let swagger_dir_path = self - .swagger_dir_path - .or(option_env!("POLARIS_SWAGGER_DIR").map(PathBuf::from)) - .unwrap_or([".", "docs", "swagger"].iter().collect()); + let swagger_dir_path = self.swagger_dir_path.unwrap_or(paths.swagger_dir_path); fs::create_dir_all(&swagger_dir_path)?; - let mut thumbnails_dir_path = self + let thumbnails_dir_path = self .cache_dir_path - .or(option_env!("POLARIS_CACHE_DIR").map(PathBuf::from)) - .unwrap_or(PathBuf::from(".").to_owned()); - thumbnails_dir_path.push("thumbnails"); + .unwrap_or(paths.cache_dir_path) + .join("thumbnails"); let vfs_manager = vfs::Manager::new(db.clone()); let settings_manager = settings::Manager::new(db.clone());