From fe529543a911d0b1aace7a2434a3776dcfd75673 Mon Sep 17 00:00:00 2001 From: Brendan Allan Date: Mon, 1 Aug 2022 11:30:10 +0800 Subject: [PATCH] fix almos all lint errors --- core/src/file/cas/identifier.rs | 1 - core/src/file/explorer/open.rs | 53 ++++++++++++++++----------------- core/src/tag/mod.rs | 10 ++----- lefthook.yml | 4 +-- 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/core/src/file/cas/identifier.rs b/core/src/file/cas/identifier.rs index a2f329365..c8bef854b 100644 --- a/core/src/file/cas/identifier.rs +++ b/core/src/file/cas/identifier.rs @@ -9,7 +9,6 @@ use crate::{ sys::LocationResource, }; use chrono::{DateTime, FixedOffset}; -use futures::future::join_all; use log::{error, info}; use prisma_client_rust::{prisma_models::PrismaValue, raw, raw::Raw, Direction}; use serde::{Deserialize, Serialize}; diff --git a/core/src/file/explorer/open.rs b/core/src/file/explorer/open.rs index 966a27d83..330ba151a 100644 --- a/core/src/file/explorer/open.rs +++ b/core/src/file/explorer/open.rs @@ -2,9 +2,8 @@ use crate::{ encode::THUMBNAIL_CACHE_DIR_NAME, file::{DirectoryWithContents, FileError, FilePath}, library::LibraryContext, - prisma::{file_path, tag, tag_on_file}, + prisma::file_path, sys::get_location, - tag::{Tag, TagError, TagOnFile, TagWithFiles}, }; use log::info; use std::path::Path; @@ -67,28 +66,28 @@ pub async fn open_dir( }) } -pub async fn open_tag(ctx: &LibraryContext, tag_id: i32) -> Result { - let tag: Tag = ctx - .db - .tag() - .find_unique(tag::id::equals(tag_id)) - .exec() - .await? - .ok_or(TagError::TagNotFound(tag_id))? - .into(); - - let files_with_tag: Vec = ctx - .db - .tag_on_file() - .find_many(vec![tag_on_file::tag_id::equals(tag_id)]) - .exec() - .await? - .into_iter() - .map(Into::into) - .collect(); - - Ok(TagWithFiles { - tag, - files_with_tag, - }) -} +// pub async fn open_tag(ctx: &LibraryContext, tag_id: i32) -> Result { +// let tag: Tag = ctx +// .db +// .tag() +// .find_unique(tag::id::equals(tag_id)) +// .exec() +// .await? +// .ok_or(TagError::TagNotFound(tag_id))? +// .into(); +// +// let files_with_tag: Vec = ctx +// .db +// .tag_on_file() +// .find_many(vec![tag_on_file::tag_id::equals(tag_id)]) +// .exec() +// .await? +// .into_iter() +// .map(Into::into) +// .collect(); +// +// Ok(TagWithFiles { +// tag, +// files_with_tag, +// }) +// } diff --git a/core/src/tag/mod.rs b/core/src/tag/mod.rs index e6da9476b..9cf480010 100644 --- a/core/src/tag/mod.rs +++ b/core/src/tag/mod.rs @@ -1,11 +1,7 @@ use crate::{ file::File, library::LibraryContext, - prisma::{ - self, file, - tag::{self}, - tag_on_file, - }, + prisma::{self, file, tag, tag_on_file}, ClientQuery, CoreError, CoreEvent, CoreResponse, LibraryQuery, }; use serde::{Deserialize, Serialize}; @@ -76,8 +72,8 @@ pub struct TagWithFiles { #[derive(Error, Debug)] pub enum TagError { - #[error("Tag not found")] - TagNotFound(i32), + // #[error("Tag not found")] + // TagNotFound(i32), #[error("Database error")] DatabaseError(#[from] prisma::QueryError), } diff --git a/lefthook.yml b/lefthook.yml index 4b4b62880..f2a0ef333 100644 --- a/lefthook.yml +++ b/lefthook.yml @@ -11,7 +11,7 @@ pre-commit: run: pnpm typecheck lint: glob: '*.{ts,tsx}' - run: pnpm eslint {all_files} + run: pnpm eslint {staged_files} spelling: glob: '*.{ts,tsx,md,rs}' run: pnpm cspell {staged_files} @@ -25,8 +25,6 @@ pre-commit: run: cargo clippy --package spacedrive -- -D warnings rust-lint-core: run: cargo clippy --package sdcore --lib -- -D warnings - rust-lint-core-prisma: - run: cargo clippy --package prisma-cli -- -D warnings rust-lint-core-derive: run: cargo clippy --package core-derive --lib -- -D warnings rust-lint-server: