fix warnings

This commit is contained in:
Aiden McClelland
2021-09-01 17:57:24 -06:00
committed by Aiden McClelland
parent 824bccda0e
commit 5d44519d0d
20 changed files with 68 additions and 199 deletions

View File

@@ -1,104 +1,33 @@
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# https://www.nginx.com/resources/wiki/start/
# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/
# https://wiki.debian.org/Nginx/DirectoryStructure
#
# In most cases, administrators will remove this file from sites-enabled/ and
# leave it as reference inside of sites-available where it will continue to be
# updated by the nginx packaging team.
#
# This file will automatically load configuration files provided by other
# applications, such as Drupal or Wordpress. These applications will be made
# available underneath a path with that package name, such as /drupal8.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
server_name _;
proxy_buffering off;
proxy_request_buffering off;
proxy_socket_keepalive on;
proxy_http_version 1.1;
proxy_request_buffering off;
location /rpc/ {
proxy_pass http://localhost:5959/;
}
location /rpc {
proxy_pass http://localhost:5959/;
}
location /ws/ {
proxy_pass http://localhost:5960/;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /ws/ {
proxy_pass http://localhost:5960/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /marketplace/ {
proxy_pass https://beta-registry-0-3.start9labs.com/;
}
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location / {
try_files $uri $uri/ =404;
}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}

View File

@@ -1,5 +1,5 @@
use anyhow::anyhow;
use chrono::{DateTime, Utc};
use chrono::Utc;
use indexmap::IndexMap;
use patch_db::DbHandle;
use rpc_toolkit::command;

View File

@@ -1,9 +1,8 @@
use std::net::Ipv4Addr;
use std::sync::Arc;
use indexmap::{IndexMap, IndexSet};
use patch_db::json_ptr::JsonPointer;
use patch_db::{DbHandle, HasModel, Map, MapModel, OptionModel};
use patch_db::{HasModel, Map, MapModel, OptionModel};
use reqwest::Url;
use serde::{Deserialize, Serialize};
use serde_json::Value;
@@ -16,7 +15,6 @@ use crate::s9pk::manifest::{Manifest, ManifestModel, PackageId};
use crate::status::health_check::HealthCheckId;
use crate::status::Status;
use crate::util::Version;
use crate::Error;
#[derive(Debug, Deserialize, Serialize, HasModel)]
#[serde(rename_all = "kebab-case")]
@@ -145,11 +143,11 @@ impl StaticFiles {
icon: format!("/public/package-data/{}/{}/icon.{}", id, version, icon_type),
}
}
pub fn remote(id: &PackageId, version: &Version, icon_type: &str) -> Self {
pub fn remote(id: &PackageId, version: &Version) -> Self {
StaticFiles {
license: format!("/marketplace/package/{}/{}/LICENSE.md", id, version),
instructions: format!("/marketplace/package/{}/{}/INSTRUCTIONS.md", id, version),
icon: format!("/marketplace/package/{}/{}/icon.{}", id, version, icon_type),
license: format!("/marketplace/package/license/{}?spec=={}", id, version),
instructions: format!("/marketplace/package/instructions/{}?spec=={}", id, version),
icon: format!("/marketplace/package/icon/{}?spec=={}", id, version),
}
}
}

View File

@@ -1,21 +1,18 @@
use std::collections::HashMap;
use anyhow::anyhow;
use emver::VersionRange;
use indexmap::{IndexMap, IndexSet};
use indexmap::IndexMap;
use patch_db::{DbHandle, DiffPatch, HasModel, Map, MapModel};
use serde::{Deserialize, Serialize};
use crate::action::ActionImplementation;
use crate::config::{Config, ConfigSpec};
use crate::config::Config;
use crate::db::model::CurrentDependencyInfo;
use crate::net::interface::InterfaceId;
use crate::s9pk::manifest::PackageId;
use crate::status::health_check::{HealthCheckId, HealthCheckResult, HealthCheckResultVariant};
use crate::status::{DependencyErrors, MainStatus, Status};
use crate::status::MainStatus;
use crate::util::Version;
use crate::volume::Volumes;
use crate::{Error, ResultExt as _};
use crate::Error;
#[derive(Clone, Debug, thiserror::Error, Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")]

View File

@@ -1,6 +1,5 @@
use std::borrow::{Borrow, Cow};
use std::fmt::Debug;
use std::path::Path;
use serde::{Deserialize, Deserializer, Serialize, Serializer};

View File

@@ -2,7 +2,6 @@ use std::path::PathBuf;
use rpc_toolkit::command;
use crate::context::CliContext;
use crate::s9pk::manifest::Manifest;
use crate::s9pk::reader::S9pkReader;
use crate::util::{display_none, display_serializable, IoFormat};

View File

@@ -1,19 +1,13 @@
use std::borrow::Cow;
use std::collections::HashMap;
use std::path::Path;
use anyhow::anyhow;
use bollard::image::ListImagesOptions;
use bollard::Docker;
use patch_db::{DbHandle, PatchDbHandle};
use tokio::process::Command;
use super::PKG_PUBLIC_DIR;
use crate::context::RpcContext;
use crate::db::model::{InstalledPackageDataEntry, PackageDataEntry};
use crate::dependencies::DependencyError;
use crate::s9pk::manifest::{Manifest, PackageId};
use crate::util::{Invoke, Version};
use crate::s9pk::manifest::PackageId;
use crate::util::Version;
use crate::Error;
pub async fn update_dependents<'a, Db: DbHandle, I: IntoIterator<Item = &'a PackageId>>(
@@ -171,21 +165,3 @@ pub async fn uninstall(
tx.commit(None).await?;
Ok(())
}
#[tokio::test]
async fn test() {
dbg!(
Docker::connect_with_socket_defaults()
.unwrap()
.list_images(Some(ListImagesOptions {
all: false,
filters: {
let mut f = HashMap::new();
f.insert("reference", vec!["start9/*:latest"]);
f
},
digests: false
}))
.await
);
}

View File

@@ -2,29 +2,20 @@ use std::collections::HashSet;
use std::fmt::Display;
use std::io::SeekFrom;
use std::path::Path;
use std::pin::Pin;
use std::process::Stdio;
use std::sync::atomic::{AtomicBool, AtomicU64, Ordering};
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::task::{Context, Poll};
use std::time::Duration;
use anyhow::anyhow;
use emver::VersionRange;
use futures::TryStreamExt;
use http::{HeaderMap, StatusCode};
use indexmap::{IndexMap, IndexSet};
use patch_db::json_ptr::JsonPointer;
use patch_db::{
DbHandle, HasModel, MapModel, Model, ModelData, OptionModel, PatchDbHandle, Revision,
};
use indexmap::IndexMap;
use patch_db::{DbHandle, OptionModel};
use reqwest::Response;
use rpc_toolkit::command;
use serde::{Deserialize, Serialize};
use serde_json::Value;
use sha2::{Digest, Sha256};
use tokio::fs::{File, OpenOptions};
use tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt, AsyncWrite, AsyncWriteExt};
use tokio::io::{AsyncRead, AsyncSeek, AsyncSeekExt, AsyncWriteExt};
use self::cleanup::cleanup_failed;
use crate::context::RpcContext;
@@ -74,7 +65,7 @@ pub async fn install(
let man: Manifest = man_res.json().await.with_kind(crate::ErrorKind::Registry)?;
let progress = InstallProgress::new(s9pk.content_length());
let static_files = StaticFiles::remote(&man.id, &man.version, man.assets.icon_type());
let static_files = StaticFiles::remote(&man.id, &man.version);
let mut db_handle = ctx.db.handle();
let mut tx = db_handle.begin().await?;
let mut pde = crate::db::DatabaseModel::new()

View File

@@ -6,11 +6,10 @@ use std::sync::Arc;
use std::task::{Context, Poll};
use std::time::Duration;
use patch_db::{DbHandle, HasModel, OptionModel, PatchDb, PatchDbHandle};
use patch_db::{DbHandle, HasModel, OptionModel, PatchDb};
use serde::{Deserialize, Serialize};
use tokio::io::{AsyncRead, AsyncSeek, AsyncWrite};
use crate::db::model::PackageDataEntry;
use crate::Error;
#[derive(Debug, Deserialize, Serialize, HasModel)]

View File

@@ -20,7 +20,7 @@ use crate::net::interface::InterfaceId;
use crate::net::NetController;
use crate::s9pk::manifest::{Manifest, PackageId};
use crate::util::{Container, Version};
use crate::{Error, ResultExt};
use crate::Error;
pub struct ManagerMap(RwLock<HashMap<(PackageId, Version), Arc<Manager>>>);
impl ManagerMap {

View File

@@ -1,6 +1,5 @@
use anyhow::anyhow;
use basic_cookies::Cookie;
use chrono::Utc;
use digest::Digest;
use futures::future::BoxFuture;
use futures::FutureExt;
@@ -9,9 +8,7 @@ use rpc_toolkit::command_helpers::prelude::RequestParts;
use rpc_toolkit::hyper::header::COOKIE;
use rpc_toolkit::hyper::http::Error as HttpError;
use rpc_toolkit::hyper::{Body, Request, Response};
use rpc_toolkit::rpc_server_helpers::{
noop3, noop4, to_response, DynMiddleware, DynMiddlewareStage2, DynMiddlewareStage3,
};
use rpc_toolkit::rpc_server_helpers::{noop3, to_response, DynMiddleware, DynMiddlewareStage2};
use rpc_toolkit::yajrc::RpcMethod;
use rpc_toolkit::Metadata;
use sha2::Sha256;

View File

@@ -1,6 +1,6 @@
use anyhow::anyhow;
use emver::VersionRange;
use indexmap::{IndexMap, IndexSet};
use indexmap::IndexMap;
use patch_db::HasModel;
use serde::{Deserialize, Serialize};

View File

@@ -5,14 +5,11 @@ use avahi_sys::{
avahi_entry_group_reset, avahi_free, AvahiEntryGroup,
};
use libc::c_void;
use patch_db::{DbHandle, OptionModel};
use tokio::sync::Mutex;
use torut::onion::TorSecretKeyV3;
use super::interface::InterfaceId;
use crate::s9pk::manifest::PackageId;
use crate::util::Apply;
use crate::Error;
pub struct MdnsController(Mutex<MdnsControllerInner>);
impl MdnsController {

View File

@@ -9,7 +9,7 @@ use self::mdns::MdnsController;
use self::tor::TorController;
use crate::net::interface::TorConfig;
use crate::s9pk::manifest::PackageId;
use crate::{Error, ResultExt};
use crate::Error;
pub mod interface;
#[cfg(feature = "avahi")]

View File

@@ -1,10 +1,7 @@
use std::borrow::Borrow;
use std::net::Ipv4Addr;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use chrono::{DateTime, Utc};
use indexmap::IndexMap;
use patch_db::HasModel;
use serde::{Deserialize, Serialize, Serializer};
use url::Url;
@@ -16,10 +13,9 @@ use crate::dependencies::Dependencies;
use crate::id::{Id, InvalidId, SYSTEM_ID};
use crate::migration::Migrations;
use crate::net::interface::Interfaces;
use crate::status::health_check::{HealthCheckResult, HealthChecks};
use crate::status::health_check::HealthChecks;
use crate::util::Version;
use crate::volume::Volumes;
use crate::Error;
pub const SYSTEM_PACKAGE_ID: PackageId<&'static str> = PackageId(SYSTEM_ID);

View File

@@ -1,9 +1,7 @@
use std::io::Read;
use std::path::PathBuf;
use anyhow::anyhow;
use rpc_toolkit::command;
use rpc_toolkit::yajrc::RpcError;
use crate::context::CliContext;
use crate::s9pk::builder::S9pkPacker;

View File

@@ -1,9 +1,13 @@
use crate::{Error, ErrorKind, ResultExt};
use std::cmp::Ordering;
use std::path::Path;
use std::time::Duration;
use divrem::DivRem;
use proptest_derive::Arbitrary;
use std::{cmp::Ordering, path::Path, time::Duration};
use tokio::sync::{Mutex, MutexGuard};
use crate::{Error, ErrorKind, ResultExt};
lazy_static::lazy_static! {
static ref SEMITONE_K: f64 = 2f64.powf(1f64 / 12f64);
static ref A_4: f64 = 440f64;
@@ -176,7 +180,7 @@ pub enum Semitone {
impl Semitone {
pub fn rotate(&self, n: isize) -> Semitone {
let mut temp = (*self as isize) + n;
let temp = (*self as isize) + n;
match temp.rem_euclid(12) {
0 => Semitone::C,
@@ -294,6 +298,7 @@ impl<'a> Iterator for CircleOf<'a> {
macro_rules! song {
($tempo:expr, [$($note:expr;)*]) => {
{
#[allow(dead_code)]
const fn note(semi: Semitone, octave: i8, duration: TimeSlice) -> (Option<Note>, TimeSlice) {
(
Some(Note {
@@ -303,6 +308,7 @@ macro_rules! song {
duration,
)
}
#[allow(dead_code)]
const fn rest(duration: TimeSlice) -> (Option<Note>, TimeSlice) {
(None, duration)
}

View File

@@ -2,27 +2,19 @@ use std::collections::HashMap;
use std::sync::Arc;
use anyhow::anyhow;
use bollard::container::{ListContainersOptions, StartContainerOptions, StopContainerOptions};
use bollard::models::{ContainerStateStatusEnum, ContainerSummaryInner};
use bollard::Docker;
use chrono::{DateTime, Utc};
use futures::{StreamExt, TryFutureExt};
use futures::StreamExt;
use indexmap::IndexMap;
use patch_db::{DbHandle, HasModel, Map, MapModel, Model, ModelData, ModelDataMut};
use patch_db::{DbHandle, HasModel, Map, MapModel, ModelData};
use serde::{Deserialize, Serialize};
use self::health_check::{HealthCheckId, HealthCheckResult};
use crate::action::docker::DockerAction;
use crate::context::RpcContext;
use crate::db::model::{
CurrentDependencyInfo, InstalledPackageDataEntryModel, PackageDataEntryModel,
};
use crate::dependencies::{Dependencies, DependencyError};
use crate::db::model::CurrentDependencyInfo;
use crate::dependencies::DependencyError;
use crate::manager::{Manager, Status as ManagerStatus};
use crate::net::interface::InterfaceId;
use crate::s9pk::manifest::{Manifest, PackageId};
use crate::status::health_check::HealthCheckResultVariant;
use crate::util::Invoke;
use crate::Error;
pub mod health_check;
@@ -326,7 +318,7 @@ impl DependencyErrors {
current_dependencies: &IndexMap<PackageId, CurrentDependencyInfo>,
) -> Result<DependencyErrors, Error> {
let mut res = IndexMap::new();
for (dep_id, info) in current_dependencies {
for dep_id in current_dependencies.keys() {
if let Err(e) = manifest
.dependencies
.0

View File

@@ -1,7 +1,7 @@
use std::future::Future;
use std::hash::{Hash, Hasher};
use std::marker::PhantomData;
use std::ops::{Deref, DerefMut};
use std::ops::Deref;
use std::path::Path;
use std::process::{exit, Stdio};
use std::str::FromStr;
@@ -9,14 +9,13 @@ use std::time::Duration;
use anyhow::anyhow;
use async_trait::async_trait;
use clap::{Arg, ArgMatches};
use clap::ArgMatches;
use digest::Digest;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_json::Value;
use sqlx::{Executor, Sqlite};
use tokio::fs::File;
use tokio::io::{AsyncRead, AsyncReadExt, AsyncWrite, AsyncWriteExt, ReadBuf};
use tokio::sync::{Mutex, RwLock};
use tokio::sync::RwLock;
use crate::{Error, ResultExt as _};
@@ -770,7 +769,7 @@ impl IoFormat {
pub fn display_serializable<T: Serialize>(t: T, matches: &ArgMatches<'_>) {
let format = match matches.value_of("format").map(|f| f.parse()) {
Some(Ok(f)) => f,
Some(Err(e)) => {
Some(Err(_)) => {
eprintln!("unrecognized formatter");
exit(1)
}
@@ -791,7 +790,7 @@ pub fn parse_stdin_deserializable<T: for<'de> Deserialize<'de>>(
) -> Result<T, Error> {
let format = match matches.value_of("format").map(|f| f.parse()) {
Some(Ok(f)) => f,
Some(Err(e)) => {
Some(Err(_)) => {
eprintln!("unrecognized formatter");
exit(1)
}
@@ -800,7 +799,7 @@ pub fn parse_stdin_deserializable<T: for<'de> Deserialize<'de>>(
format.from_reader(stdin)
}
pub fn parse_duration(arg: &str, matches: &ArgMatches<'_>) -> Result<Duration, Error> {
pub fn parse_duration(arg: &str, _: &ArgMatches<'_>) -> Result<Duration, Error> {
let units_idx = arg.find(|c: char| c.is_alphabetic()).ok_or_else(|| {
Error::new(
anyhow!("Must specify units for duration"),

View File

@@ -1,11 +1,11 @@
use std::cmp::Ordering;
use async_trait::async_trait;
use futures::stream::TryStreamExt;
use lazy_static::lazy_static;
use patch_db::DbHandle;
use rpc_toolkit::command;
use tokio_compat_02::FutureExt;
use crate::Error;
// mod v0_1_0;
// mod v0_1_1;
@@ -31,10 +31,6 @@ use tokio_compat_02::FutureExt;
// pub use v0_2_12::Version as Current;
pub type Current = ();
use crate::context::{CliContext, RpcContext};
use crate::util::{to_yaml_async_writer, AsyncCompat};
use crate::{Error, ResultExt as _};
#[derive(serde::Serialize, serde::Deserialize)]
#[serde(untagged)]
enum Version {