Skip to content

Commit

Permalink
Merge torrust#757: Update dependencies
Browse files Browse the repository at this point in the history
80ce924 chore(deps): bump derive_more from 0.99.18 to 1.0.0 (Jose Celano)
02e29e9 chore(deps): update deps (Jose Celano)

Pull request description:

  ```output
  cargo update
      Updating crates.io index
       Locking 74 packages to latest compatible versions
      Updating addr2line v0.24.1 -> v0.24.2
      Updating anstream v0.6.15 -> v0.6.17
      Updating anstyle v1.0.8 -> v1.0.9
      Updating anstyle-parse v0.2.5 -> v0.2.6
      Updating anstyle-query v1.1.1 -> v1.1.2
      Updating anstyle-wincon v3.0.4 -> v3.0.6
      Updating anyhow v1.0.89 -> v1.0.92
      Updating async-compression v0.4.13 -> v0.4.17
      Updating aws-lc-rs v1.9.0 -> v1.10.0
      Updating aws-lc-sys v0.21.2 -> v0.22.0
      Updating bindgen v0.69.4 -> v0.69.5
      Updating bytemuck v1.18.0 -> v1.19.0
      Updating bytes v1.7.2 -> v1.8.0
      Updating cc v1.1.24 -> v1.1.31
      Updating clap v4.5.19 -> v4.5.20
      Updating clap_builder v4.5.19 -> v4.5.20
      Updating colorchoice v1.0.2 -> v1.0.3
      Updating encoding_rs v0.8.34 -> v0.8.35
      Updating fdeflate v0.3.5 -> v0.3.6
      Updating flume v0.11.0 -> v0.11.1
      Updating futures v0.3.30 -> v0.3.31
      Updating futures-channel v0.3.30 -> v0.3.31
      Updating futures-core v0.3.30 -> v0.3.31
      Updating futures-executor v0.3.30 -> v0.3.31
      Updating futures-io v0.3.30 -> v0.3.31
      Updating futures-macro v0.3.30 -> v0.3.31
      Updating futures-sink v0.3.30 -> v0.3.31
      Updating futures-task v0.3.30 -> v0.3.31
      Updating futures-util v0.3.30 -> v0.3.31
      Updating gimli v0.31.0 -> v0.31.1
      Updating hyper v1.4.1 -> v1.5.0
      Updating hyper-util v0.1.9 -> v0.1.10
      Updating ipnet v2.10.0 -> v2.10.1
      Updating js-sys v0.3.70 -> v0.3.72
      Updating lettre v0.11.9 -> v0.11.10
      Updating libc v0.2.159 -> v0.2.161
      Updating libm v0.2.8 -> v0.2.11
      Updating object v0.36.4 -> v0.36.5
      Updating once_cell v1.20.1 -> v1.20.2
      Updating openssl v0.10.66 -> v0.10.68
      Updating openssl-sys v0.9.103 -> v0.9.104
      Updating pest v2.7.13 -> v2.7.14
      Updating pest_derive v2.7.13 -> v2.7.14
      Updating pest_generator v2.7.13 -> v2.7.14
      Updating pest_meta v2.7.13 -> v2.7.14
      Updating pin-project v1.1.5 -> v1.1.7
      Updating pin-project-internal v1.1.5 -> v1.1.7
      Updating pin-project-lite v0.2.14 -> v0.2.15
      Removing portable-atomic v1.9.0
      Updating prettyplease v0.2.22 -> v0.2.25
      Updating proc-macro2 v1.0.86 -> v1.0.89
      Updating regex v1.11.0 -> v1.11.1
      Updating reqwest v0.12.8 -> v0.12.9
      Updating rustix v0.38.37 -> v0.38.38
      Updating rustls v0.23.13 -> v0.23.16
      Updating rustls-pki-types v1.9.0 -> v1.10.0
      Updating rustversion v1.0.17 -> v1.0.18
      Updating schannel v0.1.24 -> v0.1.26
      Updating serde v1.0.210 -> v1.0.214
      Updating serde_derive v1.0.210 -> v1.0.214
      Updating serde_with v3.10.0 -> v3.11.0
      Updating serde_with_macros v3.10.0 -> v3.11.0
      Updating syn v2.0.79 -> v2.0.86
      Updating thiserror v1.0.65 -> v1.0.66
      Updating thiserror-impl v1.0.65 -> v1.0.66
      Updating tokio v1.40.0 -> v1.41.0
      Updating unicase v2.7.0 -> v2.8.0
      Updating uuid v1.10.0 -> v1.11.0
      Updating wasm-bindgen v0.2.93 -> v0.2.95
      Updating wasm-bindgen-backend v0.2.93 -> v0.2.95
      Updating wasm-bindgen-futures v0.4.43 -> v0.4.45
      Updating wasm-bindgen-macro v0.2.93 -> v0.2.95
      Updating wasm-bindgen-macro-support v0.2.93 -> v0.2.95
      Updating wasm-bindgen-shared v0.2.93 -> v0.2.95
      Updating web-sys v0.3.70 -> v0.3.72
  ```

ACKs for top commit:
  josecelano:
    ACK 80ce924

Tree-SHA512: 962c679dc8099c09ae8c554d4b7c1dc5f05326a8594bd048fd065f0d556485c963c6ce28650afec16fefb1eefcaa8b88988a3f427a28955020a73b4a30b0dd67
  • Loading branch information
josecelano committed Nov 1, 2024
2 parents c34b665 + 80ce924 commit 5c38420
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 303 deletions.
417 changes: 199 additions & 218 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ camino = { version = "1", features = ["serde"] }
casbin = "2"
chrono = { version = "0", default-features = false, features = ["clock"] }
clap = { version = "4", features = ["derive", "env"] }
derive_more = "0"
derive_more = { version = "1", features = ["display", "error"] }
email_address = "0"
figment = { version = "0", features = ["env", "test", "toml"] }
futures = "0"
Expand Down
2 changes: 1 addition & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub const LATEST_VERSION: &str = "2.0.0";

/// Info about the configuration specification.
#[derive(Serialize, Deserialize, PartialEq, Eq, Debug, Display, Clone)]
#[display(fmt = "Metadata(app: {app}, purpose: {purpose}, schema_version: {schema_version})")]
#[display("Metadata(app: {app}, purpose: {purpose}, schema_version: {schema_version})")]
pub struct Metadata {
/// The application this configuration is valid for.
#[serde(default = "Metadata::default_app")]
Expand Down
2 changes: 1 addition & 1 deletion src/console/commands/tracker_statistics_importer/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const NUMBER_OF_ARGUMENTS: usize = 0;
#[derive(Debug, Display, PartialEq, Error)]
#[allow(dead_code)]
pub enum ImportError {
#[display(fmt = "internal server error")]
#[display("internal server error")]
WrongNumberOfArgumentsError,
}

Expand Down
106 changes: 52 additions & 54 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,167 +14,165 @@ pub type ServiceResult<V> = Result<V, ServiceError>;
#[derive(Debug, Display, PartialEq, Eq, Error)]
#[allow(dead_code)]
pub enum ServiceError {
#[display(fmt = "internal server error")]
#[display("internal server error")]
InternalServerError,

#[display(fmt = "This server is is closed for registration. Contact admin if this is unexpected")]
#[display("This server is is closed for registration. Contact admin if this is unexpected")]
ClosedForRegistration,

#[display(fmt = "Email is required")] //405j
#[display("Email is required")] //405j
EmailMissing,
#[display(fmt = "Please enter a valid email address")] //405j
#[display("Please enter a valid email address")] //405j
EmailInvalid,

#[display(fmt = "The value you entered for URL is not a URL")] //405j
#[display("The value you entered for URL is not a URL")] //405j
NotAUrl,

#[display(fmt = "Invalid username/email or password")]
#[display("Invalid username/email or password")]
WrongPasswordOrUsername,
#[display(fmt = "Invalid password")]
#[display("Invalid password")]
InvalidPassword,
#[display(fmt = "Username not found")]
#[display("Username not found")]
UsernameNotFound,
#[display(fmt = "User not found")]
#[display("User not found")]
UserNotFound,

#[display(fmt = "Account not found")]
#[display("Account not found")]
AccountNotFound,

/// when the value passed contains profanity
#[display(fmt = "Can't allow profanity in usernames")]
#[display("Can't allow profanity in usernames")]
ProfanityError,
/// when the value passed contains blacklisted words
/// see [blacklist](https://github.com/shuttlecraft/The-Big-Username-Blacklist)
#[display(fmt = "Username contains blacklisted words")]
#[display("Username contains blacklisted words")]
BlacklistError,
/// when the value passed contains characters not present
/// in [UsernameCaseMapped](https://tools.ietf.org/html/rfc8265#page-7)
/// profile
#[display(fmt = "username_case_mapped violation")]
#[display("username_case_mapped violation")]
UsernameCaseMappedError,

#[display(fmt = "Password too short")]
#[display("Password too short")]
PasswordTooShort,
#[display(fmt = "Password too long")]
#[display("Password too long")]
PasswordTooLong,
#[display(fmt = "Passwords don't match")]
#[display("Passwords don't match")]
PasswordsDontMatch,

/// when the a username is already taken
#[display(fmt = "Username not available")]
#[display("Username not available")]
UsernameTaken,

#[display(fmt = "Invalid username. Usernames must consist of 1-20 alphanumeric characters, dashes, or underscore")]
#[display("Invalid username. Usernames must consist of 1-20 alphanumeric characters, dashes, or underscore")]
UsernameInvalid,

/// email is already taken
#[display(fmt = "Email not available")]
#[display("Email not available")]
EmailTaken,

#[display(fmt = "Please verify your email before logging in")]
#[display("Please verify your email before logging in")]
EmailNotVerified,

/// when the a token name is already taken
/// token not found
#[display(fmt = "Token not found. Please sign in.")]
#[display("Token not found. Please sign in.")]
TokenNotFound,

/// token expired
#[display(fmt = "Token expired. Please sign in again.")]
#[display("Token expired. Please sign in again.")]
TokenExpired,

#[display(fmt = "Token invalid.")]
#[display("Token invalid.")]
/// token invalid
TokenInvalid,

#[display(fmt = "Uploaded torrent is not valid.")]
#[display("Uploaded torrent is not valid.")]
InvalidTorrentFile,

#[display(fmt = "Uploaded torrent has an invalid pieces key.")]
#[display("Uploaded torrent has an invalid pieces key.")]
InvalidTorrentPiecesLength,

#[display(fmt = "Only .torrent files can be uploaded.")]
#[display("Only .torrent files can be uploaded.")]
InvalidFileType,

#[display(fmt = "Torrent title is too short.")]
#[display("Torrent title is too short.")]
InvalidTorrentTitleLength,

#[display(fmt = "Some mandatory metadata fields are missing.")]
#[display("Some mandatory metadata fields are missing.")]
MissingMandatoryMetadataFields,

#[display(fmt = "Selected category does not exist.")]
#[display("Selected category does not exist.")]
InvalidCategory,

#[display(fmt = "Selected tag does not exist.")]
#[display("Selected tag does not exist.")]
InvalidTag,

#[display(fmt = "Unauthorized action.")]
#[display("Unauthorized action.")]
UnauthorizedAction,

#[display(
fmt = "Unauthorized actions for guest users. Try logging in to check if you have permission to perform the action"
)]
#[display("Unauthorized actions for guest users. Try logging in to check if you have permission to perform the action")]
UnauthorizedActionForGuests,

#[display(fmt = "This torrent already exists in our database.")]
#[display("This torrent already exists in our database.")]
InfoHashAlreadyExists,

#[display(fmt = "A torrent with the same canonical infohash already exists in our database.")]
#[display("A torrent with the same canonical infohash already exists in our database.")]
CanonicalInfoHashAlreadyExists,

#[display(fmt = "A torrent with the same original infohash already exists in our database.")]
#[display("A torrent with the same original infohash already exists in our database.")]
OriginalInfoHashAlreadyExists,

#[display(fmt = "This torrent title has already been used.")]
#[display("This torrent title has already been used.")]
TorrentTitleAlreadyExists,

#[display(fmt = "Could not whitelist torrent.")]
#[display("Could not whitelist torrent.")]
WhitelistingError,

#[display(fmt = "Failed to send verification email.")]
#[display("Failed to send verification email.")]
FailedToSendVerificationEmail,

#[display(fmt = "Category already exists.")]
#[display("Category already exists.")]
CategoryAlreadyExists,

#[display(fmt = "Category name cannot be empty.")]
#[display("Category name cannot be empty.")]
CategoryNameEmpty,

#[display(fmt = "Tag already exists.")]
#[display("Tag already exists.")]
TagAlreadyExists,

#[display(fmt = "Tag name cannot be empty.")]
#[display("Tag name cannot be empty.")]
TagNameEmpty,

#[display(fmt = "Torrent not found.")]
#[display("Torrent not found.")]
TorrentNotFound,

#[display(fmt = "Category not found.")]
#[display("Category not found.")]
CategoryNotFound,

#[display(fmt = "Tag not found.")]
#[display("Tag not found.")]
TagNotFound,

#[display(fmt = "Database error.")]
#[display("Database error.")]
DatabaseError,

#[display(fmt = "Authentication error, please sign in")]
#[display("Authentication error, please sign in")]
LoggedInUserNotFound,

// Begin tracker errors
#[display(fmt = "Sorry, we have an error with our tracker connection.")]
#[display("Sorry, we have an error with our tracker connection.")]
TrackerOffline,

#[display(fmt = "Tracker response error. The operation could not be performed.")]
#[display("Tracker response error. The operation could not be performed.")]
TrackerResponseError,

#[display(fmt = "Tracker unknown response. Unexpected response from tracker. For example, if it can't be parsed.")]
#[display("Tracker unknown response. Unexpected response from tracker. For example, if it can't be parsed.")]
TrackerUnknownResponse,

#[display(fmt = "Torrent not found in tracker.")]
#[display("Torrent not found in tracker.")]
TorrentNotFoundInTracker,

#[display(fmt = "Invalid tracker API token.")]
#[display("Invalid tracker API token.")]
InvalidTrackerToken,
// End tracker errors
}
Expand Down
4 changes: 2 additions & 2 deletions src/models/torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ pub struct TorrentListing {

#[derive(Debug, Display, PartialEq, Eq, Error)]
pub enum MetadataError {
#[display(fmt = "Missing mandatory torrent title.")]
#[display("Missing mandatory torrent title.")]
MissingTorrentTitle,

#[display(fmt = "Torrent title is too short.")]
#[display("Torrent title is too short.")]
InvalidTorrentTitleLength,
}

Expand Down
18 changes: 9 additions & 9 deletions src/tracker/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,31 @@ use crate::models::user::UserId;
#[derive(Debug, Display, PartialEq, Eq, Error)]
#[allow(dead_code)]
pub enum TrackerAPIError {
#[display(fmt = "Error with tracker request: {error}.")]
#[display("Error with tracker request: {error}.")]
TrackerOffline { error: String },

#[display(fmt = "Invalid token for tracker API. Check the tracker token in settings.")]
#[display("Invalid token for tracker API. Check the tracker token in settings.")]
InvalidToken,

#[display(fmt = "Tracker returned an internal server error.")]
#[display("Tracker returned an internal server error.")]
InternalServerError,

#[display(fmt = "Tracker returned a not found error.")]
#[display("Tracker returned a not found error.")]
NotFound,

#[display(fmt = "Tracker returned an unexpected response status.")]
#[display("Tracker returned an unexpected response status.")]
UnexpectedResponseStatus,

#[display(fmt = "Could not save the newly generated user key into the database.")]
#[display("Could not save the newly generated user key into the database.")]
CannotSaveUserKey,

#[display(fmt = "Torrent not found.")]
#[display("Torrent not found.")]
TorrentNotFound,

#[display(fmt = "Expected body in tracker response, received empty body.")]
#[display("Expected body in tracker response, received empty body.")]
MissingResponseBody,

#[display(fmt = "Expected body in tracker response, received empty body.")]
#[display("Expected body in tracker response, received empty body.")]
FailedToParseTrackerResponse { body: String },
}

Expand Down
12 changes: 6 additions & 6 deletions src/utils/parse_torrent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,23 @@ use bittorrent_primitives::info_hash::InfoHash;
use derive_more::{Display, Error};
use serde::{Deserialize, Serialize};
use serde_bencode::value::Value;
use serde_bencode::{de, Error};
use serde_bencode::{de, Error as SerdeError};
use sha1::{Digest, Sha1};

use crate::models::torrent_file::Torrent;

#[derive(Debug, Display, PartialEq, Eq, Error)]
pub enum DecodeTorrentFileError {
#[display(fmt = "Torrent data could not be decoded from the bencoded format.")]
#[display("Torrent data could not be decoded from the bencoded format.")]
InvalidBencodeData,

#[display(fmt = "Torrent info dictionary key could not be decoded from the bencoded format.")]
#[display("Torrent info dictionary key could not be decoded from the bencoded format.")]
InvalidInfoDictionary,

#[display(fmt = "Torrent has an invalid pieces key length. It should be a multiple of 20.")]
#[display("Torrent has an invalid pieces key length. It should be a multiple of 20.")]
InvalidTorrentPiecesLength,

#[display(fmt = "Cannot bencode the parsed `info` dictionary again to generate the info-hash.")]
#[display("Cannot bencode the parsed `info` dictionary again to generate the info-hash.")]
CannotBencodeInfoDict,
}

Expand Down Expand Up @@ -72,7 +72,7 @@ pub fn decode_torrent(bytes: &[u8]) -> Result<Torrent, Box<dyn error::Error>> {
/// # Errors
///
/// This function will return an error if unable to bencode torrent.
pub fn encode_torrent(torrent: &Torrent) -> Result<Vec<u8>, Error> {
pub fn encode_torrent(torrent: &Torrent) -> Result<Vec<u8>, SerdeError> {
match serde_bencode::to_bytes(torrent) {
Ok(bencode_bytes) => Ok(bencode_bytes),
Err(e) => {
Expand Down
20 changes: 9 additions & 11 deletions src/web/api/server/v1/contexts/torrent/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,31 @@ use crate::web::api::server::v1::responses::{json_error_response, ErrorResponseD

#[derive(Debug, Display, PartialEq, Eq, Error)]
pub enum Request {
#[display(fmt = "torrent title bytes are nota valid UTF8 string.")]
#[display("torrent title bytes are nota valid UTF8 string.")]
TitleIsNotValidUtf8,

#[display(fmt = "torrent description bytes are nota valid UTF8 string.")]
#[display("torrent description bytes are nota valid UTF8 string.")]
DescriptionIsNotValidUtf8,

#[display(fmt = "torrent category bytes are nota valid UTF8 string.")]
#[display("torrent category bytes are nota valid UTF8 string.")]
CategoryIsNotValidUtf8,

#[display(fmt = "torrent tags arrays bytes are nota valid UTF8 string array.")]
#[display("torrent tags arrays bytes are nota valid UTF8 string array.")]
TagsArrayIsNotValidUtf8,

#[display(fmt = "torrent tags string is not a valid JSON.")]
#[display("torrent tags string is not a valid JSON.")]
TagsArrayIsNotValidJson,

#[display(
fmt = "upload torrent request header `content-type` should be preferably `application/x-bittorrent` or `application/octet-stream`."
)]
#[display("upload torrent request header `content-type` should be preferably `application/x-bittorrent` or `application/octet-stream`.")]
InvalidFileType,

#[display(fmt = "cannot write uploaded torrent bytes (binary file) into memory.")]
#[display("cannot write uploaded torrent bytes (binary file) into memory.")]
CannotWriteChunkFromUploadedBinary,

#[display(fmt = "cannot read a chunk of bytes from the uploaded torrent file. Review the request body size limit.")]
#[display("cannot read a chunk of bytes from the uploaded torrent file. Review the request body size limit.")]
CannotReadChunkFromUploadedBinary,

#[display(fmt = "provided path param for Info-hash is not valid.")]
#[display("provided path param for Info-hash is not valid.")]
InvalidInfoHashParam,
}

Expand Down

0 comments on commit 5c38420

Please sign in to comment.