fix almos all lint errors

This commit is contained in:
Brendan Allan
2022-08-01 11:30:10 +08:00
parent 7c3b51868b
commit fe529543a9
4 changed files with 30 additions and 38 deletions

View File

@@ -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};

View File

@@ -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<TagWithFiles, TagError> {
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<TagOnFile> = 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<TagWithFiles, TagError> {
// 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<TagOnFile> = 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,
// })
// }

View File

@@ -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),
}

View File

@@ -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: