mirror of
https://github.com/timvisee/ffsend.git
synced 2025-10-03 17:49:15 +02:00
Lowercase all error messages
This commit is contained in:
parent
f348e603e2
commit
34aff28b10
29 changed files with 166 additions and 178 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Release 0.1
|
# Release 0.1
|
||||||
|
- Print nice error in `cli/cmd/arg/download_limit.rs`
|
||||||
|
- Resolve panics with a nice error message
|
||||||
- Panic when secret is missing from URL with info action
|
- Panic when secret is missing from URL with info action
|
||||||
- Lowercase error messages
|
|
||||||
- Switch to `directories` instead of `app_dirs2`?
|
- Switch to `directories` instead of `app_dirs2`?
|
||||||
- Allow file/directory archiving on upload
|
- Allow file/directory archiving on upload
|
||||||
- Allow unarchiving on download
|
- Allow unarchiving on download
|
||||||
|
|
|
@ -90,16 +90,16 @@ impl DeleteData {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while preparing the action.
|
/// An error occurred while preparing the action.
|
||||||
#[fail(display = "Failed to prepare the action")]
|
#[fail(display = "failed to prepare the action")]
|
||||||
Prepare(#[cause] PrepareError),
|
Prepare(#[cause] PrepareError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
/// Therefore the file could not be downloaded.
|
/// Therefore the file could not be downloaded.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// An error has occurred while sending the filedeletion request.
|
/// An error has occurred while sending the filedeletion request.
|
||||||
#[fail(display = "Failed to send the file deletion request")]
|
#[fail(display = "failed to send the file deletion request")]
|
||||||
Delete(#[cause] DeleteError),
|
Delete(#[cause] DeleteError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,23 +136,23 @@ pub enum DeleteDataError {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum PrepareError {
|
pub enum PrepareError {
|
||||||
/// Failed to authenticate
|
/// Failed to authenticate
|
||||||
#[fail(display = "Failed to authenticate")]
|
#[fail(display = "failed to authenticate")]
|
||||||
Auth(#[cause] NonceError),
|
Auth(#[cause] NonceError),
|
||||||
|
|
||||||
/// An error occurred while building the deletion data that will be
|
/// An error occurred while building the deletion data that will be
|
||||||
/// send to the server.
|
/// send to the server.
|
||||||
#[fail(display = "Invalid parameters")]
|
#[fail(display = "invalid parameters")]
|
||||||
DeleteData(#[cause] DeleteDataError),
|
DeleteData(#[cause] DeleteDataError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum DeleteError {
|
pub enum DeleteError {
|
||||||
/// Sending the file deletion request failed.
|
/// Sending the file deletion request failed.
|
||||||
#[fail(display = "Failed to send file deletion request")]
|
#[fail(display = "failed to send file deletion request")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while requesting file deletion.
|
/// The server responded with an error while requesting file deletion.
|
||||||
#[fail(display = "Bad response from server while deleting file")]
|
#[fail(display = "bad response from server while deleting file")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,29 +253,29 @@ pub enum Error {
|
||||||
/// An error occurred while fetching the metadata of the file.
|
/// An error occurred while fetching the metadata of the file.
|
||||||
/// This step is required in order to succsessfully decrypt the
|
/// This step is required in order to succsessfully decrypt the
|
||||||
/// file that will be downloaded.
|
/// file that will be downloaded.
|
||||||
#[fail(display = "Failed to fetch file metadata")]
|
#[fail(display = "failed to fetch file metadata")]
|
||||||
Meta(#[cause] MetadataError),
|
Meta(#[cause] MetadataError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
/// Therefore the file could not be downloaded.
|
/// Therefore the file could not be downloaded.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// A password is required, but was not given.
|
/// A password is required, but was not given.
|
||||||
#[fail(display = "Missing password, password required")]
|
#[fail(display = "missing password, password required")]
|
||||||
PasswordRequired,
|
PasswordRequired,
|
||||||
|
|
||||||
/// An error occurred while downloading the file.
|
/// An error occurred while downloading the file.
|
||||||
#[fail(display = "Failed to download the file")]
|
#[fail(display = "failed to download the file")]
|
||||||
Download(#[cause] DownloadError),
|
Download(#[cause] DownloadError),
|
||||||
|
|
||||||
/// An error occurred while decrypting the downloaded file.
|
/// An error occurred while decrypting the downloaded file.
|
||||||
#[fail(display = "Failed to decrypt the downloaded file")]
|
#[fail(display = "failed to decrypt the downloaded file")]
|
||||||
Decrypt,
|
Decrypt,
|
||||||
|
|
||||||
/// An error occurred while opening or writing to the target file.
|
/// An error occurred while opening or writing to the target file.
|
||||||
// TODO: show what file this is about
|
// TODO: show what file this is about
|
||||||
#[fail(display = "Couldn't use the target file at '{}'", _0)]
|
#[fail(display = "couldn't use the target file at '{}'", _0)]
|
||||||
File(String, #[cause] FileError),
|
File(String, #[cause] FileError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -299,46 +299,46 @@ impl From<DownloadError> for Error {
|
||||||
pub enum DownloadError {
|
pub enum DownloadError {
|
||||||
/// An error occurred while computing the cryptographic signature used for
|
/// An error occurred while computing the cryptographic signature used for
|
||||||
/// downloading the file.
|
/// downloading the file.
|
||||||
#[fail(display = "Failed to compute cryptographic signature")]
|
#[fail(display = "failed to compute cryptographic signature")]
|
||||||
ComputeSignature,
|
ComputeSignature,
|
||||||
|
|
||||||
/// Sending the request to download the file failed.
|
/// Sending the request to download the file failed.
|
||||||
#[fail(display = "Failed to request file download")]
|
#[fail(display = "failed to request file download")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while requesting the file download.
|
/// The server responded with an error while requesting the file download.
|
||||||
#[fail(display = "Bad response from server while requesting download")]
|
#[fail(display = "bad response from server while requesting download")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
|
|
||||||
/// The length of the file is missing, thus the length of the file to download
|
/// The length of the file is missing, thus the length of the file to download
|
||||||
/// couldn't be determined.
|
/// couldn't be determined.
|
||||||
#[fail(display = "Couldn't determine file download length, missing property")]
|
#[fail(display = "couldn't determine file download length, missing property")]
|
||||||
NoLength,
|
NoLength,
|
||||||
|
|
||||||
/// Failed to start or update the downloading progress, because of this the
|
/// Failed to start or update the downloading progress, because of this the
|
||||||
/// download can't continue.
|
/// download can't continue.
|
||||||
#[fail(display = "Failed to update download progress")]
|
#[fail(display = "failed to update download progress")]
|
||||||
Progress,
|
Progress,
|
||||||
|
|
||||||
/// The actual download and decryption process the server.
|
/// The actual download and decryption process the server.
|
||||||
/// This covers reading the file from the server, decrypting the file,
|
/// This covers reading the file from the server, decrypting the file,
|
||||||
/// and writing it to the file system.
|
/// and writing it to the file system.
|
||||||
#[fail(display = "Failed to download the file")]
|
#[fail(display = "failed to download the file")]
|
||||||
Download,
|
Download,
|
||||||
|
|
||||||
/// Verifying the downloaded file failed.
|
/// Verifying the downloaded file failed.
|
||||||
#[fail(display = "File verification failed")]
|
#[fail(display = "file verification failed")]
|
||||||
Verify,
|
Verify,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum FileError {
|
pub enum FileError {
|
||||||
/// An error occurred while creating or opening the file to write to.
|
/// An error occurred while creating or opening the file to write to.
|
||||||
#[fail(display = "Failed to create or replace the file")]
|
#[fail(display = "failed to create or replace the file")]
|
||||||
Create(#[cause] IoError),
|
Create(#[cause] IoError),
|
||||||
|
|
||||||
/// Failed to create an encrypted writer for the file, which is used to
|
/// Failed to create an encrypted writer for the file, which is used to
|
||||||
/// decrypt the downloaded file.
|
/// decrypt the downloaded file.
|
||||||
#[fail(display = "Failed to create file decryptor")]
|
#[fail(display = "failed to create file decryptor")]
|
||||||
EncryptedWriter,
|
EncryptedWriter,
|
||||||
}
|
}
|
||||||
|
|
|
@ -102,18 +102,18 @@ impl Default for ExistsResponse {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Sending the request to check whether the file exists failed.
|
/// Sending the request to check whether the file exists failed.
|
||||||
#[fail(display = "Failed to send request whether the file exists")]
|
#[fail(display = "failed to send request whether the file exists")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while checking whether the file
|
/// The server responded with an error while checking whether the file
|
||||||
/// exists.
|
/// exists.
|
||||||
#[fail(display = "Bad response from server while checking file existence")]
|
#[fail(display = "bad response from server while checking file existence")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
|
|
||||||
/// The response from the server when checking if the file exists was
|
/// The response from the server when checking if the file exists was
|
||||||
/// malformed.
|
/// malformed.
|
||||||
/// Maybe the server responded with a new format that isn't supported yet
|
/// Maybe the server responded with a new format that isn't supported yet
|
||||||
/// by this client.
|
/// by this client.
|
||||||
#[fail(display = "Received malformed authentication nonce")]
|
#[fail(display = "received malformed authentication nonce")]
|
||||||
Malformed,
|
Malformed,
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,16 +139,16 @@ impl InfoResponse {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while preparing the action.
|
/// An error occurred while preparing the action.
|
||||||
#[fail(display = "Failed to prepare the action")]
|
#[fail(display = "failed to prepare the action")]
|
||||||
Prepare(#[cause] PrepareError),
|
Prepare(#[cause] PrepareError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
/// Therefore the file could not be downloaded.
|
/// Therefore the file could not be downloaded.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// An error has occurred while sending the info request to the server.
|
/// An error has occurred while sending the info request to the server.
|
||||||
#[fail(display = "Failed to send the file info request")]
|
#[fail(display = "failed to send the file info request")]
|
||||||
Info(#[cause] InfoError),
|
Info(#[cause] InfoError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,12 +194,12 @@ pub enum InfoDataError {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum PrepareError {
|
pub enum PrepareError {
|
||||||
/// Failed authenticating, needed to fetch the info
|
/// Failed authenticating, needed to fetch the info
|
||||||
#[fail(display = "Failed to authenticate")]
|
#[fail(display = "failed to authenticate")]
|
||||||
Auth(#[cause] NonceError),
|
Auth(#[cause] NonceError),
|
||||||
|
|
||||||
/// An error occurred while building the info data that will be
|
/// An error occurred while building the info data that will be
|
||||||
/// send to the server.
|
/// send to the server.
|
||||||
#[fail(display = "Invalid parameters")]
|
#[fail(display = "invalid parameters")]
|
||||||
InfoData(#[cause] InfoDataError),
|
InfoData(#[cause] InfoDataError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,15 +212,15 @@ impl From<DataError> for PrepareError {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum InfoError {
|
pub enum InfoError {
|
||||||
/// Sending the request to fetch the file info failed.
|
/// Sending the request to fetch the file info failed.
|
||||||
#[fail(display = "Failed to send file info request")]
|
#[fail(display = "failed to send file info request")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while fetching the file info.
|
/// The server responded with an error while fetching the file info.
|
||||||
#[fail(display = "Bad response from server while fetching file info")]
|
#[fail(display = "bad response from server while fetching file info")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
|
|
||||||
/// Failed to decode the info response from the server.
|
/// Failed to decode the info response from the server.
|
||||||
/// Maybe the server responded with data from a newer API version.
|
/// Maybe the server responded with data from a newer API version.
|
||||||
#[fail(display = "Failed to decode info response")]
|
#[fail(display = "failed to decode info response")]
|
||||||
Decode(#[cause] ReqwestError),
|
Decode(#[cause] ReqwestError),
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,22 +231,22 @@ impl<'a> MetadataResponse {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while checking whether the file exists on the
|
/// An error occurred while checking whether the file exists on the
|
||||||
/// server.
|
/// server.
|
||||||
#[fail(display = "Failed to check whether the file exists")]
|
#[fail(display = "failed to check whether the file exists")]
|
||||||
Exists(#[cause] ExistsError),
|
Exists(#[cause] ExistsError),
|
||||||
|
|
||||||
/// A general error occurred while requesting the file data.
|
/// A general error occurred while requesting the file data.
|
||||||
/// This may be because authentication failed, because decrypting the
|
/// This may be because authentication failed, because decrypting the
|
||||||
/// file metadata didn't succeed, or due to some other reason.
|
/// file metadata didn't succeed, or due to some other reason.
|
||||||
#[fail(display = "Failed to request file data")]
|
#[fail(display = "failed to request file data")]
|
||||||
Request(#[cause] RequestError),
|
Request(#[cause] RequestError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
/// Therefore the file could not be downloaded.
|
/// Therefore the file could not be downloaded.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// A password is required, but was not given.
|
/// A password is required, but was not given.
|
||||||
#[fail(display = "Missing password, password required")]
|
#[fail(display = "missing password, password required")]
|
||||||
PasswordRequired,
|
PasswordRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,11 +280,11 @@ impl From<NonceError> for Error {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum RequestError {
|
pub enum RequestError {
|
||||||
/// Failed authenticating, in order to fetch the file data.
|
/// Failed authenticating, in order to fetch the file data.
|
||||||
#[fail(display = "Failed to authenticate")]
|
#[fail(display = "failed to authenticate")]
|
||||||
Auth(#[cause] NonceError),
|
Auth(#[cause] NonceError),
|
||||||
|
|
||||||
/// Failed to retrieve the file metadata.
|
/// Failed to retrieve the file metadata.
|
||||||
#[fail(display = "Failed to retrieve file metadata")]
|
#[fail(display = "failed to retrieve file metadata")]
|
||||||
Meta(#[cause] MetaError),
|
Meta(#[cause] MetaError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -292,28 +292,28 @@ pub enum RequestError {
|
||||||
pub enum MetaError {
|
pub enum MetaError {
|
||||||
/// An error occurred while computing the cryptographic signature used for
|
/// An error occurred while computing the cryptographic signature used for
|
||||||
/// decryption.
|
/// decryption.
|
||||||
#[fail(display = "Failed to compute cryptographic signature")]
|
#[fail(display = "failed to compute cryptographic signature")]
|
||||||
ComputeSignature,
|
ComputeSignature,
|
||||||
|
|
||||||
/// Sending the request to gather the metadata encryption nonce failed.
|
/// Sending the request to gather the metadata encryption nonce failed.
|
||||||
#[fail(display = "Failed to request metadata nonce")]
|
#[fail(display = "failed to request metadata nonce")]
|
||||||
NonceRequest,
|
NonceRequest,
|
||||||
|
|
||||||
/// The server responded with an error while fetching the metadata
|
/// The server responded with an error while fetching the metadata
|
||||||
/// encryption nonce.
|
/// encryption nonce.
|
||||||
#[fail(display = "Bad response from server while fetching metadata nonce")]
|
#[fail(display = "bad response from server while fetching metadata nonce")]
|
||||||
NonceResponse(#[cause] ResponseError),
|
NonceResponse(#[cause] ResponseError),
|
||||||
|
|
||||||
/// Couldn't parse the metadata encryption nonce.
|
/// Couldn't parse the metadata encryption nonce.
|
||||||
#[fail(display = "Failed to parse the metadata encryption nonce")]
|
#[fail(display = "failed to parse the metadata encryption nonce")]
|
||||||
Nonce(#[cause] NonceError),
|
Nonce(#[cause] NonceError),
|
||||||
|
|
||||||
/// The received metadata is malformed, and couldn't be decoded or
|
/// The received metadata is malformed, and couldn't be decoded or
|
||||||
/// interpreted.
|
/// interpreted.
|
||||||
#[fail(display = "Received malformed metadata")]
|
#[fail(display = "received malformed metadata")]
|
||||||
Malformed,
|
Malformed,
|
||||||
|
|
||||||
/// Failed to decrypt the received metadata.
|
/// Failed to decrypt the received metadata.
|
||||||
#[fail(display = "Failed to decrypt received metadata")]
|
#[fail(display = "failed to decrypt received metadata")]
|
||||||
Decrypt,
|
Decrypt,
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,17 +162,17 @@ impl Default for ParamsData {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while preparing the action.
|
/// An error occurred while preparing the action.
|
||||||
#[fail(display = "Failed to prepare setting the parameters")]
|
#[fail(display = "failed to prepare setting the parameters")]
|
||||||
Prepare(#[cause] PrepareError),
|
Prepare(#[cause] PrepareError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
/// Therefore the file could not be downloaded.
|
/// Therefore the file could not be downloaded.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// An error has occurred while sending the parameter change request to
|
/// An error has occurred while sending the parameter change request to
|
||||||
/// the server.
|
/// the server.
|
||||||
#[fail(display = "Failed to send the parameter change request")]
|
#[fail(display = "failed to send the parameter change request")]
|
||||||
Change(#[cause] ChangeError),
|
Change(#[cause] ChangeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ pub enum ParamsDataError {
|
||||||
/// The number of downloads is invalid, as it was out of the allowed
|
/// The number of downloads is invalid, as it was out of the allowed
|
||||||
/// bounds. See `PARAMS_DOWNLOAD_MIN` and `PARAMS_DOWNLOAD_MAX`.
|
/// bounds. See `PARAMS_DOWNLOAD_MIN` and `PARAMS_DOWNLOAD_MAX`.
|
||||||
// TODO: use bound values from constants, don't hardcode them here
|
// TODO: use bound values from constants, don't hardcode them here
|
||||||
#[fail(display = "Invalid number of downloads, must be between 1 and 20")]
|
#[fail(display = "invalid number of downloads, must be between 1 and 20")]
|
||||||
DownloadBounds,
|
DownloadBounds,
|
||||||
|
|
||||||
/// Some error occurred while trying to wrap the parameter data in an
|
/// Some error occurred while trying to wrap the parameter data in an
|
||||||
|
@ -224,12 +224,12 @@ pub enum ParamsDataError {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum PrepareError {
|
pub enum PrepareError {
|
||||||
/// Failed authenticating, needed to change the parameters.
|
/// Failed authenticating, needed to change the parameters.
|
||||||
#[fail(display = "Failed to authenticate")]
|
#[fail(display = "failed to authenticate")]
|
||||||
Auth(#[cause] NonceError),
|
Auth(#[cause] NonceError),
|
||||||
|
|
||||||
/// An error occurred while building the parameter data that will be send
|
/// An error occurred while building the parameter data that will be send
|
||||||
/// to the server.
|
/// to the server.
|
||||||
#[fail(display = "Invalid parameters")]
|
#[fail(display = "invalid parameters")]
|
||||||
ParamsData(#[cause] ParamsDataError),
|
ParamsData(#[cause] ParamsDataError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,10 +242,10 @@ impl From<DataError> for PrepareError {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum ChangeError {
|
pub enum ChangeError {
|
||||||
/// Sending the request to change the parameters failed.
|
/// Sending the request to change the parameters failed.
|
||||||
#[fail(display = "Failed to send parameter change request")]
|
#[fail(display = "failed to send parameter change request")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while changing the file parameters.
|
/// The server responded with an error while changing the file parameters.
|
||||||
#[fail(display = "Bad response from server while changing parameters")]
|
#[fail(display = "bad response from server while changing parameters")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,17 +108,17 @@ impl PasswordData {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while preparing the action.
|
/// An error occurred while preparing the action.
|
||||||
#[fail(display = "Failed to prepare setting the password")]
|
#[fail(display = "failed to prepare setting the password")]
|
||||||
Prepare(#[cause] PrepareError),
|
Prepare(#[cause] PrepareError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
/// Therefore the file could not be downloaded.
|
/// Therefore the file could not be downloaded.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// An error has occurred while sending the password change request to
|
/// An error has occurred while sending the password change request to
|
||||||
/// the server.
|
/// the server.
|
||||||
#[fail(display = "Failed to send the password change request")]
|
#[fail(display = "failed to send the password change request")]
|
||||||
Change(#[cause] ChangeError),
|
Change(#[cause] ChangeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ impl From<ResponseError> for Error {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum PrepareError {
|
pub enum PrepareError {
|
||||||
/// Failed authenticating, needed to set a new password.
|
/// Failed authenticating, needed to set a new password.
|
||||||
#[fail(display = "Failed to authenticate")]
|
#[fail(display = "failed to authenticate")]
|
||||||
Auth(#[cause] NonceError),
|
Auth(#[cause] NonceError),
|
||||||
|
|
||||||
/// Some error occurred while building the data that will be sent.
|
/// Some error occurred while building the data that will be sent.
|
||||||
|
@ -174,10 +174,10 @@ impl From<DataError> for PrepareError {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum ChangeError {
|
pub enum ChangeError {
|
||||||
/// Sending the request to change the password failed.
|
/// Sending the request to change the password failed.
|
||||||
#[fail(display = "Failed to send password change request")]
|
#[fail(display = "failed to send password change request")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while changing the file password.
|
/// The server responded with an error while changing the file password.
|
||||||
#[fail(display = "Bad response from server while changing password")]
|
#[fail(display = "bad response from server while changing password")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ impl<'a> FileData<'a> {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while preparing a file for uploading.
|
/// An error occurred while preparing a file for uploading.
|
||||||
#[fail(display = "Failed to prepare uploading the file")]
|
#[fail(display = "failed to prepare uploading the file")]
|
||||||
Prepare(#[cause] PrepareError),
|
Prepare(#[cause] PrepareError),
|
||||||
|
|
||||||
/// An error occurred while opening, reading or using the file that
|
/// An error occurred while opening, reading or using the file that
|
||||||
|
@ -365,15 +365,15 @@ pub enum Error {
|
||||||
File(#[cause] FileError),
|
File(#[cause] FileError),
|
||||||
|
|
||||||
/// An error occurred while uploading the file.
|
/// An error occurred while uploading the file.
|
||||||
#[fail(display = "Failed to upload the file")]
|
#[fail(display = "failed to upload the file")]
|
||||||
Upload(#[cause] UploadError),
|
Upload(#[cause] UploadError),
|
||||||
|
|
||||||
/// An error occurred while chaining file parameters.
|
/// An error occurred while chaining file parameters.
|
||||||
#[fail(display = "Failed to change file parameters")]
|
#[fail(display = "failed to change file parameters")]
|
||||||
Params(#[cause] ParamsError),
|
Params(#[cause] ParamsError),
|
||||||
|
|
||||||
/// An error occurred while setting the password.
|
/// An error occurred while setting the password.
|
||||||
#[fail(display = "Failed to set the password")]
|
#[fail(display = "failed to set the password")]
|
||||||
Password(#[cause] PasswordError),
|
Password(#[cause] PasswordError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -416,42 +416,42 @@ impl From<PasswordError> for Error {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum PrepareError {
|
pub enum PrepareError {
|
||||||
/// Failed to prepare the file metadata for uploading.
|
/// Failed to prepare the file metadata for uploading.
|
||||||
#[fail(display = "Failed to prepare file metadata")]
|
#[fail(display = "failed to prepare file metadata")]
|
||||||
Meta(#[cause] MetaError),
|
Meta(#[cause] MetaError),
|
||||||
|
|
||||||
/// Failed to create an encrypted file reader, that encrypts
|
/// Failed to create an encrypted file reader, that encrypts
|
||||||
/// the file on the fly when it is read.
|
/// the file on the fly when it is read.
|
||||||
#[fail(display = "Failed to access the file to upload")]
|
#[fail(display = "failed to access the file to upload")]
|
||||||
Reader(#[cause] ReaderError),
|
Reader(#[cause] ReaderError),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum MetaError {
|
pub enum MetaError {
|
||||||
/// An error occurred while encrypting the file metadata.
|
/// An error occurred while encrypting the file metadata.
|
||||||
#[fail(display = "Failed to encrypt file metadata")]
|
#[fail(display = "failed to encrypt file metadata")]
|
||||||
Encrypt,
|
Encrypt,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum ReaderError {
|
pub enum ReaderError {
|
||||||
/// An error occurred while creating the file encryptor.
|
/// An error occurred while creating the file encryptor.
|
||||||
#[fail(display = "Failed to create file encryptor")]
|
#[fail(display = "failed to create file encryptor")]
|
||||||
Encrypt,
|
Encrypt,
|
||||||
|
|
||||||
/// Failed to create the progress reader, attached to the file reader,
|
/// Failed to create the progress reader, attached to the file reader,
|
||||||
/// to measure the uploading progress.
|
/// to measure the uploading progress.
|
||||||
#[fail(display = "Failed to create progress reader")]
|
#[fail(display = "failed to create progress reader")]
|
||||||
Progress,
|
Progress,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum FileError {
|
pub enum FileError {
|
||||||
/// The given path, is not not a file or doesn't exist.
|
/// The given path, is not not a file or doesn't exist.
|
||||||
#[fail(display = "The given path is not an existing file")]
|
#[fail(display = "the given path is not an existing file")]
|
||||||
NotAFile,
|
NotAFile,
|
||||||
|
|
||||||
/// Failed to open the file that must be uploaded for reading.
|
/// Failed to open the file that must be uploaded for reading.
|
||||||
#[fail(display = "Failed to open the file to upload")]
|
#[fail(display = "failed to open the file to upload")]
|
||||||
Open(#[cause] IoError),
|
Open(#[cause] IoError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,24 +459,24 @@ pub enum FileError {
|
||||||
pub enum UploadError {
|
pub enum UploadError {
|
||||||
/// Failed to start or update the uploading progress, because of this the
|
/// Failed to start or update the uploading progress, because of this the
|
||||||
/// upload can't continue.
|
/// upload can't continue.
|
||||||
#[fail(display = "Failed to update upload progress")]
|
#[fail(display = "failed to update upload progress")]
|
||||||
Progress,
|
Progress,
|
||||||
|
|
||||||
/// Sending the request to upload the file failed.
|
/// Sending the request to upload the file failed.
|
||||||
#[fail(display = "Failed to request file upload")]
|
#[fail(display = "failed to request file upload")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while uploading.
|
/// The server responded with an error while uploading.
|
||||||
#[fail(display = "Bad response from server while uploading")]
|
#[fail(display = "bad response from server while uploading")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
|
|
||||||
/// Failed to decode the upload response from the server.
|
/// Failed to decode the upload response from the server.
|
||||||
/// Maybe the server responded with data from a newer API version.
|
/// Maybe the server responded with data from a newer API version.
|
||||||
#[fail(display = "Failed to decode upload response")]
|
#[fail(display = "failed to decode upload response")]
|
||||||
Decode(#[cause] ReqwestError),
|
Decode(#[cause] ReqwestError),
|
||||||
|
|
||||||
/// Failed to parse the retrieved URL from the upload response.
|
/// Failed to parse the retrieved URL from the upload response.
|
||||||
#[fail(display = "Failed to parse received URL")]
|
#[fail(display = "failed to parse received URL")]
|
||||||
ParseUrl(#[cause] UrlParseError),
|
ParseUrl(#[cause] UrlParseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,6 @@ impl<D> OwnedData<D>
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Missing owner token, which is required.
|
/// Missing owner token, which is required.
|
||||||
#[fail(display = "Missing owner token, must be specified")]
|
#[fail(display = "missing owner token, must be specified")]
|
||||||
NoOwnerToken,
|
NoOwnerToken,
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,26 +49,26 @@ pub fn header_nonce(response: &Response)
|
||||||
pub enum NonceError {
|
pub enum NonceError {
|
||||||
/// Sending the request to fetch a nonce failed,
|
/// Sending the request to fetch a nonce failed,
|
||||||
/// as the file has expired or did never exist.
|
/// as the file has expired or did never exist.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// Sending the request to fetch a nonce failed.
|
/// Sending the request to fetch a nonce failed.
|
||||||
#[fail(display = "Failed to request encryption nonce")]
|
#[fail(display = "failed to request encryption nonce")]
|
||||||
Request,
|
Request,
|
||||||
|
|
||||||
/// The server responded with an error while requesting the encryption nonce,
|
/// The server responded with an error while requesting the encryption nonce,
|
||||||
/// required for some operations.
|
/// required for some operations.
|
||||||
#[fail(display = "Bad response from server while requesting encryption nonce")]
|
#[fail(display = "bad response from server while requesting encryption nonce")]
|
||||||
Response(#[cause] ResponseError),
|
Response(#[cause] ResponseError),
|
||||||
|
|
||||||
/// The nonce header was missing from the request.
|
/// The nonce header was missing from the request.
|
||||||
#[fail(display = "Missing nonce in server response")]
|
#[fail(display = "missing nonce in server response")]
|
||||||
NoNonceHeader,
|
NoNonceHeader,
|
||||||
|
|
||||||
/// The received nonce could not be parsed, because it was malformed.
|
/// The received nonce could not be parsed, because it was malformed.
|
||||||
/// Maybe the server responded with a new format that isn't supported yet
|
/// Maybe the server responded with a new format that isn't supported yet
|
||||||
/// by this client.
|
/// by this client.
|
||||||
#[fail(display = "Received malformed nonce")]
|
#[fail(display = "received malformed nonce")]
|
||||||
MalformedNonce,
|
MalformedNonce,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,15 +30,15 @@ pub fn ensure_success(response: &Response) -> Result<(), ResponseError> {
|
||||||
#[derive(Fail, Debug)]
|
#[derive(Fail, Debug)]
|
||||||
pub enum ResponseError {
|
pub enum ResponseError {
|
||||||
/// This request lead to an expired file, or a file that never existed.
|
/// This request lead to an expired file, or a file that never existed.
|
||||||
#[fail(display = "This file has expired or did never exist")]
|
#[fail(display = "this file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// We were unauthorized to make this request.
|
/// We were unauthorized to make this request.
|
||||||
/// This is usually because of an incorrect password.
|
/// This is usually because of an incorrect password.
|
||||||
#[fail(display = "Unauthorized, are the credentials correct?")]
|
#[fail(display = "unauthorized, are the credentials correct?")]
|
||||||
Unauthorized,
|
Unauthorized,
|
||||||
|
|
||||||
/// Some undefined error occurred with this response.
|
/// Some undefined error occurred with this response.
|
||||||
#[fail(display = "Bad HTTP response: {}", _1)]
|
#[fail(display = "bad HTTP response: {}", _1)]
|
||||||
Other(StatusCode, String),
|
Other(StatusCode, String),
|
||||||
}
|
}
|
||||||
|
|
|
@ -325,14 +325,14 @@ impl RemoteFile {
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum FileParseError {
|
pub enum FileParseError {
|
||||||
/// An URL format error.
|
/// An URL format error.
|
||||||
#[fail(display = "Failed to parse remote file, invalid URL format")]
|
#[fail(display = "failed to parse remote file, invalid URL format")]
|
||||||
UrlFormatError(#[cause] UrlParseError),
|
UrlFormatError(#[cause] UrlParseError),
|
||||||
|
|
||||||
/// An error for an invalid share URL format.
|
/// An error for an invalid share URL format.
|
||||||
#[fail(display = "Failed to parse remote file, invalid URL")]
|
#[fail(display = "failed to parse remote file, invalid URL")]
|
||||||
InvalidUrl,
|
InvalidUrl,
|
||||||
|
|
||||||
/// An error for an invalid secret format, if an URL fragmet exists.
|
/// An error for an invalid secret format, if an URL fragmet exists.
|
||||||
#[fail(display = "Failed to parse remote file, invalid secret in URL")]
|
#[fail(display = "failed to parse remote file, invalid secret in URL")]
|
||||||
InvalidSecret,
|
InvalidSecret,
|
||||||
}
|
}
|
||||||
|
|
|
@ -514,21 +514,6 @@ impl Write for EncryptedFileWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// A writer wrapper, that measures the reading process for a writer with a
|
/// A writer wrapper, that measures the reading process for a writer with a
|
||||||
/// known length.
|
/// known length.
|
||||||
///
|
///
|
||||||
|
|
|
@ -73,15 +73,15 @@ impl<'a> Delete<'a> {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to parse a share URL, it was invalid.
|
/// Failed to parse a share URL, it was invalid.
|
||||||
/// This error is not related to a specific action.
|
/// This error is not related to a specific action.
|
||||||
#[fail(display = "Invalid share URL")]
|
#[fail(display = "invalid share URL")]
|
||||||
InvalidUrl(#[cause] FileParseError),
|
InvalidUrl(#[cause] FileParseError),
|
||||||
|
|
||||||
/// Could not delete, the file has expired or did never exist.
|
/// Could not delete, the file has expired or did never exist.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
|
|
||||||
/// An error occurred while deleting the remote file.
|
/// An error occurred while deleting the remote file.
|
||||||
#[fail(display = "Failed to delete the shared file")]
|
#[fail(display = "failed to delete the shared file")]
|
||||||
Delete(#[cause] DeleteError),
|
Delete(#[cause] DeleteError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,12 +172,12 @@ impl<'a> Download<'a> {
|
||||||
// Create the parent directories
|
// Create the parent directories
|
||||||
if let Err(err) = create_dir_all(parent) {
|
if let Err(err) = create_dir_all(parent) {
|
||||||
quit_error(err.context(
|
quit_error(err.context(
|
||||||
"Failed to create parent directories for output file",
|
"failed to create parent directories for output file",
|
||||||
), ErrorHints::default());
|
), ErrorHints::default());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
None => quit_error_msg(
|
None => quit_error_msg(
|
||||||
"Invalid output file path",
|
"invalid output file path",
|
||||||
ErrorHints::default(),
|
ErrorHints::default(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ impl<'a> Download<'a> {
|
||||||
match target.canonicalize() {
|
match target.canonicalize() {
|
||||||
Ok(target) => return target,
|
Ok(target) => return target,
|
||||||
Err(err) => quit_error(
|
Err(err) => quit_error(
|
||||||
err.context("Failed to canonicalize target path"),
|
err.context("failed to canonicalize target path"),
|
||||||
ErrorHints::default(),
|
ErrorHints::default(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ impl<'a> Download<'a> {
|
||||||
match target.canonicalize() {
|
match target.canonicalize() {
|
||||||
Ok(target) => return target.join(name_hint),
|
Ok(target) => return target.join(name_hint),
|
||||||
Err(err) => quit_error(
|
Err(err) => quit_error(
|
||||||
err.context("Failed to canonicalize target path"),
|
err.context("failed to canonicalize target path"),
|
||||||
ErrorHints::default(),
|
ErrorHints::default(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ impl<'a> Download<'a> {
|
||||||
match current_dir() {
|
match current_dir() {
|
||||||
Ok(target) => return target.join(name_hint),
|
Ok(target) => return target.join(name_hint),
|
||||||
Err(err) => quit_error(err.context(
|
Err(err) => quit_error(err.context(
|
||||||
"Failed to determine working directory to use for the output file"
|
"failed to determine working directory to use for the output file"
|
||||||
), ErrorHints::default()),
|
), ErrorHints::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,7 +247,7 @@ impl<'a> Download<'a> {
|
||||||
match current_dir() {
|
match current_dir() {
|
||||||
Ok(workdir) => target = workdir.join(target),
|
Ok(workdir) => target = workdir.join(target),
|
||||||
Err(err) => quit_error(err.context(
|
Err(err) => quit_error(err.context(
|
||||||
"Failed to determine working directory to use for the output file"
|
"failed to determine working directory to use for the output file"
|
||||||
), ErrorHints::default()),
|
), ErrorHints::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -260,15 +260,15 @@ impl<'a> Download<'a> {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to parse a share URL, it was invalid.
|
/// Failed to parse a share URL, it was invalid.
|
||||||
/// This error is not related to a specific action.
|
/// This error is not related to a specific action.
|
||||||
#[fail(display = "Invalid share URL")]
|
#[fail(display = "invalid share URL")]
|
||||||
InvalidUrl(#[cause] FileParseError),
|
InvalidUrl(#[cause] FileParseError),
|
||||||
|
|
||||||
/// An error occurred while checking if the file exists.
|
/// An error occurred while checking if the file exists.
|
||||||
#[fail(display = "Failed to check whether the file exists")]
|
#[fail(display = "failed to check whether the file exists")]
|
||||||
Exists(#[cause] ExistsError),
|
Exists(#[cause] ExistsError),
|
||||||
|
|
||||||
/// An error occurred while fetching metadata.
|
/// An error occurred while fetching metadata.
|
||||||
#[fail(display = "Failed to fetch file metadata")]
|
#[fail(display = "failed to fetch file metadata")]
|
||||||
Metadata(#[cause] MetadataError),
|
Metadata(#[cause] MetadataError),
|
||||||
|
|
||||||
/// An error occurred while downloading the file.
|
/// An error occurred while downloading the file.
|
||||||
|
@ -276,7 +276,7 @@ pub enum Error {
|
||||||
Download(#[cause] DownloadError),
|
Download(#[cause] DownloadError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,11 +72,11 @@ impl<'a> Exists<'a> {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to parse a share URL, it was invalid.
|
/// Failed to parse a share URL, it was invalid.
|
||||||
/// This error is not related to a specific action.
|
/// This error is not related to a specific action.
|
||||||
#[fail(display = "Invalid share URL")]
|
#[fail(display = "invalid share URL")]
|
||||||
InvalidUrl(#[cause] FileParseError),
|
InvalidUrl(#[cause] FileParseError),
|
||||||
|
|
||||||
/// An error occurred while checking if the file exists.
|
/// An error occurred while checking if the file exists.
|
||||||
#[fail(display = "Failed to check whether the file exists")]
|
#[fail(display = "failed to check whether the file exists")]
|
||||||
Exists(#[cause] ExistsError),
|
Exists(#[cause] ExistsError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ impl<'a> History<'a> {
|
||||||
// Get the history path, make sure it exists
|
// Get the history path, make sure it exists
|
||||||
let history_path = matcher_main.history();
|
let history_path = matcher_main.history();
|
||||||
if !history_path.is_file() {
|
if !history_path.is_file() {
|
||||||
println!("No files in history");
|
eprintln!("No files in history");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ impl<'a> History<'a> {
|
||||||
|
|
||||||
// Do not report any files if there aren't any
|
// Do not report any files if there aren't any
|
||||||
if history.files().is_empty() {
|
if history.files().is_empty() {
|
||||||
println!("No files in history");
|
eprintln!("No files in history");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl<'a> Info<'a> {
|
||||||
let metadata = ApiMetadata::new(&file, password, false)
|
let metadata = ApiMetadata::new(&file, password, false)
|
||||||
.invoke(&client)
|
.invoke(&client)
|
||||||
.map_err(|err| print_error(err.context(
|
.map_err(|err| print_error(err.context(
|
||||||
"Failed to fetch file metadata, showing limited info",
|
"failed to fetch file metadata, showing limited info",
|
||||||
)))
|
)))
|
||||||
.ok();
|
.ok();
|
||||||
|
|
||||||
|
@ -124,19 +124,19 @@ impl<'a> Info<'a> {
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// Failed to parse a share URL, it was invalid.
|
/// Failed to parse a share URL, it was invalid.
|
||||||
/// This error is not related to a specific action.
|
/// This error is not related to a specific action.
|
||||||
#[fail(display = "Invalid share URL")]
|
#[fail(display = "invalid share URL")]
|
||||||
InvalidUrl(#[cause] FileParseError),
|
InvalidUrl(#[cause] FileParseError),
|
||||||
|
|
||||||
/// An error occurred while checking if the file exists.
|
/// An error occurred while checking if the file exists.
|
||||||
#[fail(display = "Failed to check whether the file exists")]
|
#[fail(display = "failed to check whether the file exists")]
|
||||||
Exists(#[cause] ExistsError),
|
Exists(#[cause] ExistsError),
|
||||||
|
|
||||||
/// An error occurred while fetching the file information.
|
/// An error occurred while fetching the file information.
|
||||||
#[fail(display = "Failed to fetch file info")]
|
#[fail(display = "failed to fetch file info")]
|
||||||
Info(#[cause] InfoError),
|
Info(#[cause] InfoError),
|
||||||
|
|
||||||
/// The given Send file has expired, or did never exist in the first place.
|
/// The given Send file has expired, or did never exist in the first place.
|
||||||
#[fail(display = "The file has expired or did never exist")]
|
#[fail(display = "the file has expired or did never exist")]
|
||||||
Expired,
|
Expired,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ impl<'a> Upload<'a> {
|
||||||
// The file is too large, show an error and quit
|
// The file is too large, show an error and quit
|
||||||
quit_error_msg(
|
quit_error_msg(
|
||||||
format!(
|
format!(
|
||||||
"The file size is {}, bigger than the maximum allowed of {}",
|
"the file size is {}, bigger than the maximum allowed of {}",
|
||||||
format_bytes(size),
|
format_bytes(size),
|
||||||
format_bytes(UPLOAD_SIZE_MAX),
|
format_bytes(UPLOAD_SIZE_MAX),
|
||||||
),
|
),
|
||||||
|
@ -74,7 +74,7 @@ impl<'a> Upload<'a> {
|
||||||
} else if size > UPLOAD_SIZE_MAX_RECOMMENDED && !matcher_main.force() {
|
} else if size > UPLOAD_SIZE_MAX_RECOMMENDED && !matcher_main.force() {
|
||||||
// The file is larger than the recommended maximum, warn
|
// The file is larger than the recommended maximum, warn
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"The file size is {}, bigger than the recommended maximum of {}",
|
"the file size is {}, bigger than the recommended maximum of {}",
|
||||||
format_bytes(size),
|
format_bytes(size),
|
||||||
format_bytes(UPLOAD_SIZE_MAX_RECOMMENDED),
|
format_bytes(UPLOAD_SIZE_MAX_RECOMMENDED),
|
||||||
);
|
);
|
||||||
|
@ -86,7 +86,7 @@ impl<'a> Upload<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
print_error_msg("Failed to check the file size, ignoring");
|
print_error_msg("failed to check the file size, ignoring");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a reqwest client
|
// Create a reqwest client
|
||||||
|
@ -132,7 +132,7 @@ impl<'a> Upload<'a> {
|
||||||
if matcher_upload.open() {
|
if matcher_upload.open() {
|
||||||
if let Err(err) = open_url(url.clone()) {
|
if let Err(err) = open_url(url.clone()) {
|
||||||
print_error(
|
print_error(
|
||||||
err.context("Failed to open the URL in the browser")
|
err.context("failed to open the URL in the browser")
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ impl<'a> Upload<'a> {
|
||||||
if matcher_upload.copy() {
|
if matcher_upload.copy() {
|
||||||
if set_clipboard(url.as_str().to_owned()).is_err() {
|
if set_clipboard(url.as_str().to_owned()).is_err() {
|
||||||
print_error(
|
print_error(
|
||||||
err_msg("Failed to copy the URL to the clipboard")
|
err_msg("failed to copy the URL to the clipboard")
|
||||||
.compat()
|
.compat()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ impl<'a> CmdArgOption<'a> for ArgDownloadLimit {
|
||||||
.map(|d| d.parse::<u8>().expect("invalid download limit"))
|
.map(|d| d.parse::<u8>().expect("invalid download limit"))
|
||||||
.and_then(|d| {
|
.and_then(|d| {
|
||||||
// Check the download limit bounds
|
// Check the download limit bounds
|
||||||
|
// TODO: print a nicely formatted error here
|
||||||
if d < DOWNLOAD_MIN || d > DOWNLOAD_MAX {
|
if d < DOWNLOAD_MIN || d > DOWNLOAD_MAX {
|
||||||
panic!(
|
panic!(
|
||||||
"invalid download limit, must be between {} and {}",
|
"invalid download limit, must be between {} and {}",
|
||||||
|
|
|
@ -37,7 +37,7 @@ impl<'a> CmdArgOption<'a> for ArgHost {
|
||||||
match parse_host(&url) {
|
match parse_host(&url) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
Err(err) => quit_error(
|
Err(err) => quit_error(
|
||||||
err.context("Failed to parse the given host"),
|
err.context("failed to parse the given host"),
|
||||||
ErrorHints::default(),
|
ErrorHints::default(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ impl<'a> CmdArgOption<'a> for ArgUrl {
|
||||||
match parse_host(&url) {
|
match parse_host(&url) {
|
||||||
Ok(url) => url,
|
Ok(url) => url,
|
||||||
Err(err) => quit_error(
|
Err(err) => quit_error(
|
||||||
err.context("Failed to parse the given share URL"),
|
err.context("failed to parse the given share URL"),
|
||||||
ErrorHints::default(),
|
ErrorHints::default(),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl<'a: 'b, 'b> MainMatcher<'a> {
|
||||||
match path {
|
match path {
|
||||||
Some(path) => path,
|
Some(path) => path,
|
||||||
None => quit_error_msg(
|
None => quit_error_msg(
|
||||||
"History file path not set",
|
"history file path not set",
|
||||||
ErrorHintsBuilder::default()
|
ErrorHintsBuilder::default()
|
||||||
.history(true)
|
.history(true)
|
||||||
.verbose(false)
|
.verbose(false)
|
||||||
|
|
|
@ -37,41 +37,41 @@ impl From<ActionError> for Error {
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum ActionError {
|
pub enum ActionError {
|
||||||
/// An error occurred while invoking the delete action.
|
/// An error occurred while invoking the delete action.
|
||||||
#[fail(display = "Failed to delete the file")]
|
#[fail(display = "failed to delete the file")]
|
||||||
Delete(#[cause] DeleteError),
|
Delete(#[cause] DeleteError),
|
||||||
|
|
||||||
/// An error occurred while invoking the download action.
|
/// An error occurred while invoking the download action.
|
||||||
#[fail(display = "Failed to download the requested file")]
|
#[fail(display = "failed to download the requested file")]
|
||||||
Download(#[cause] CliDownloadError),
|
Download(#[cause] CliDownloadError),
|
||||||
|
|
||||||
/// An error occurred while invoking the exists action.
|
/// An error occurred while invoking the exists action.
|
||||||
#[fail(display = "Failed to check whether the file exists")]
|
#[fail(display = "failed to check whether the file exists")]
|
||||||
Exists(#[cause] ExistsError),
|
Exists(#[cause] ExistsError),
|
||||||
|
|
||||||
/// An error occurred while processing the file history.
|
/// An error occurred while processing the file history.
|
||||||
#[fail(display = "Failed to process the history")]
|
#[fail(display = "failed to process the history")]
|
||||||
History(#[cause] CliHistoryError),
|
History(#[cause] CliHistoryError),
|
||||||
|
|
||||||
/// An error occurred while invoking the info action.
|
/// An error occurred while invoking the info action.
|
||||||
#[fail(display = "Failed to fetch file info")]
|
#[fail(display = "failed to fetch file info")]
|
||||||
Info(#[cause] CliInfoError),
|
Info(#[cause] CliInfoError),
|
||||||
|
|
||||||
/// An error occurred while invoking the params action.
|
/// An error occurred while invoking the params action.
|
||||||
#[fail(display = "Failed to change the parameters")]
|
#[fail(display = "failed to change the parameters")]
|
||||||
Params(#[cause] ParamsError),
|
Params(#[cause] ParamsError),
|
||||||
|
|
||||||
/// An error occurred while invoking the password action.
|
/// An error occurred while invoking the password action.
|
||||||
#[fail(display = "Failed to change the password")]
|
#[fail(display = "failed to change the password")]
|
||||||
Password(#[cause] PasswordError),
|
Password(#[cause] PasswordError),
|
||||||
|
|
||||||
/// An error occurred while invoking the upload action.
|
/// An error occurred while invoking the upload action.
|
||||||
// TODO: bind the upload cause here
|
// TODO: bind the upload cause here
|
||||||
#[fail(display = "Failed to upload the specified file")]
|
#[fail(display = "failed to upload the specified file")]
|
||||||
Upload(#[cause] UploadError),
|
Upload(#[cause] UploadError),
|
||||||
|
|
||||||
/// Failed to parse a share URL, it was invalid.
|
/// Failed to parse a share URL, it was invalid.
|
||||||
/// This error is not related to a specific action.
|
/// This error is not related to a specific action.
|
||||||
#[fail(display = "Invalid share URL")]
|
#[fail(display = "invalid share URL")]
|
||||||
InvalidUrl(#[cause] FileParseError),
|
InvalidUrl(#[cause] FileParseError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,9 +74,9 @@ impl History {
|
||||||
let version = history.version.as_ref().unwrap();
|
let version = history.version.as_ref().unwrap();
|
||||||
|
|
||||||
if let Ok(true) = VersionCompare::compare_to(version, VERSION_MIN, &CompOp::Lt) {
|
if let Ok(true) = VersionCompare::compare_to(version, VERSION_MIN, &CompOp::Lt) {
|
||||||
print_warning("History file version is too old, ignoring");
|
print_warning("history file version is too old, ignoring");
|
||||||
} else if let Ok(true) = VersionCompare::compare_to(version, VERSION_MAX, &CompOp::Gt) {
|
} else if let Ok(true) = VersionCompare::compare_to(version, VERSION_MAX, &CompOp::Gt) {
|
||||||
print_warning("History file has an unknown version, ignoring");
|
print_warning("history file has an unknown version, ignoring");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ impl Drop for History {
|
||||||
// Save and report errors
|
// Save and report errors
|
||||||
if let Err(err) = self.save() {
|
if let Err(err) = self.save() {
|
||||||
print_error(
|
print_error(
|
||||||
err.context("Failed to auto save history, ignoring"),
|
err.context("failed to auto save history, ignoring"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,11 +265,11 @@ impl Default for History {
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
/// An error occurred while loading the history from a file.
|
/// An error occurred while loading the history from a file.
|
||||||
#[fail(display = "Failed to load history from file")]
|
#[fail(display = "failed to load history from file")]
|
||||||
Load(#[cause] LoadError),
|
Load(#[cause] LoadError),
|
||||||
|
|
||||||
/// An error occurred while saving the history to a file.
|
/// An error occurred while saving the history to a file.
|
||||||
#[fail(display = "Failed to save history to file")]
|
#[fail(display = "failed to save history to file")]
|
||||||
Save(#[cause] SaveError),
|
Save(#[cause] SaveError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,20 +311,20 @@ impl From<DeError> for LoadError {
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum SaveError {
|
pub enum SaveError {
|
||||||
/// No autosave file path was present, failed to save.
|
/// No autosave file path was present, failed to save.
|
||||||
#[fail(display = "No autosave file path specified")]
|
#[fail(display = "no autosave file path specified")]
|
||||||
NoPath,
|
NoPath,
|
||||||
|
|
||||||
/// Failed to serialize the history for saving.
|
/// Failed to serialize the history for saving.
|
||||||
#[fail(display = "Failed to serialize the history for saving")]
|
#[fail(display = "failed to serialize the history for saving")]
|
||||||
Serialize(#[cause] SerError),
|
Serialize(#[cause] SerError),
|
||||||
|
|
||||||
/// Failed to write to the history file.
|
/// Failed to write to the history file.
|
||||||
#[fail(display = "Failed to write to the history file")]
|
#[fail(display = "failed to write to the history file")]
|
||||||
Write(#[cause] IoError),
|
Write(#[cause] IoError),
|
||||||
|
|
||||||
/// Failed to delete the history file, which was tried because there
|
/// Failed to delete the history file, which was tried because there
|
||||||
/// are no history items to save.
|
/// are no history items to save.
|
||||||
#[fail(display = "Failed to delete history file, because history is empty")]
|
#[fail(display = "failed to delete history file, because history is empty")]
|
||||||
Delete(#[cause] IoError),
|
Delete(#[cause] IoError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ fn add_error(matcher_main: &MainMatcher, file: RemoteFile, overwrite: bool)
|
||||||
pub fn add(matcher_main: &MainMatcher, file: RemoteFile, overwrite: bool) {
|
pub fn add(matcher_main: &MainMatcher, file: RemoteFile, overwrite: bool) {
|
||||||
if let Err(err) = add_error(matcher_main, file, overwrite) {
|
if let Err(err) = add_error(matcher_main, file, overwrite) {
|
||||||
print_error(err.context(
|
print_error(err.context(
|
||||||
"Failed to add file to local history, ignoring",
|
"failed to add file to local history, ignoring",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ pub fn remove(matcher_main: &MainMatcher, file: &RemoteFile) -> bool {
|
||||||
let ok = result.is_ok();
|
let ok = result.is_ok();
|
||||||
if let Err(err) = result {
|
if let Err(err) = result {
|
||||||
print_error(err.context(
|
print_error(err.context(
|
||||||
"Failed to remove file from local history, ignoring",
|
"failed to remove file from local history, ignoring",
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
ok
|
ok
|
||||||
|
@ -109,7 +109,7 @@ pub fn derive_owner_token(matcher_main: &MainMatcher, file: &mut RemoteFile) ->
|
||||||
Ok(history) => history,
|
Ok(history) => history,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
print_error(err.context(
|
print_error(err.context(
|
||||||
"Failed to derive file owner token from history, ignoring",
|
"failed to derive file owner token from history, ignoring",
|
||||||
));
|
));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,34 +26,34 @@ pub fn parse_host(host: &str) -> Result<Url, HostError> {
|
||||||
#[derive(Debug, Fail)]
|
#[derive(Debug, Fail)]
|
||||||
pub enum HostError {
|
pub enum HostError {
|
||||||
/// The URL scheme is missing or invalid.
|
/// The URL scheme is missing or invalid.
|
||||||
#[fail(display = "The URL must have the 'https://' or 'http://' scheme")]
|
#[fail(display = "the URL must have the 'https://' or 'http://' scheme")]
|
||||||
Scheme,
|
Scheme,
|
||||||
|
|
||||||
/// The host address is empty.
|
/// The host address is empty.
|
||||||
#[fail(display = "Empty host address")]
|
#[fail(display = "empty host address")]
|
||||||
Empty,
|
Empty,
|
||||||
|
|
||||||
/// The port number is invalid.
|
/// The port number is invalid.
|
||||||
#[fail(display = "Invalid port")]
|
#[fail(display = "invalid port")]
|
||||||
Port,
|
Port,
|
||||||
|
|
||||||
/// The given IPv4 styled address is invalid.
|
/// The given IPv4 styled address is invalid.
|
||||||
#[fail(display = "Invalid IPv4 address in the host")]
|
#[fail(display = "invalid IPv4 address in the host")]
|
||||||
Ipv4,
|
Ipv4,
|
||||||
|
|
||||||
/// The given IPv6 styled address is invalid.
|
/// The given IPv6 styled address is invalid.
|
||||||
#[fail(display = "Invalid IPv6 address in the host")]
|
#[fail(display = "invalid IPv6 address in the host")]
|
||||||
Ipv6,
|
Ipv6,
|
||||||
|
|
||||||
/// The domain contains an invalid character.
|
/// The domain contains an invalid character.
|
||||||
#[fail(display = "Invalid character in the domain")]
|
#[fail(display = "invalid character in the domain")]
|
||||||
DomainCharacter,
|
DomainCharacter,
|
||||||
|
|
||||||
/// The base host is missing from the host URL.
|
/// The base host is missing from the host URL.
|
||||||
#[fail(display = "Missing host in the host URL")]
|
#[fail(display = "missing host in the host URL")]
|
||||||
NoBase,
|
NoBase,
|
||||||
|
|
||||||
/// Failed to parse the host URL due to another reason.
|
/// Failed to parse the host URL due to another reason.
|
||||||
#[fail(display = "Could not parse host URL")]
|
#[fail(display = "could not parse host URL")]
|
||||||
Other(#[cause] ParseError),
|
Other(#[cause] ParseError),
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ pub fn print_error<E: Fail>(err: E) {
|
||||||
|
|
||||||
// Fall back to a basic message
|
// Fall back to a basic message
|
||||||
if count == 0 {
|
if count == 0 {
|
||||||
eprintln!("{} {}", highlight_error("error:"), "An undefined error occurred");
|
eprintln!("{} {}", highlight_error("error:"), "an undefined error occurred");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +250,7 @@ pub fn set_clipboard(content: String) -> Result<(), Box<StdError>> {
|
||||||
pub fn check_empty_password(password: &str, matcher_main: &MainMatcher) {
|
pub fn check_empty_password(password: &str, matcher_main: &MainMatcher) {
|
||||||
if !matcher_main.force() && password.is_empty() {
|
if !matcher_main.force() && password.is_empty() {
|
||||||
quit_error_msg(
|
quit_error_msg(
|
||||||
"An empty password is not supported by the web interface",
|
"an empty password is not supported by the web interface",
|
||||||
ErrorHintsBuilder::default()
|
ErrorHintsBuilder::default()
|
||||||
.force(true)
|
.force(true)
|
||||||
.verbose(false)
|
.verbose(false)
|
||||||
|
@ -267,7 +267,7 @@ pub fn prompt_password(main_matcher: &MainMatcher) -> String {
|
||||||
// Quit with an error if we may not interact
|
// Quit with an error if we may not interact
|
||||||
if main_matcher.no_interact() {
|
if main_matcher.no_interact() {
|
||||||
quit_error_msg(
|
quit_error_msg(
|
||||||
"Missing password, must be specified in no-interact mode",
|
"missing password, must be specified in no-interact mode",
|
||||||
ErrorHintsBuilder::default()
|
ErrorHintsBuilder::default()
|
||||||
.password(true)
|
.password(true)
|
||||||
.verbose(false)
|
.verbose(false)
|
||||||
|
@ -280,7 +280,7 @@ pub fn prompt_password(main_matcher: &MainMatcher) -> String {
|
||||||
match prompt_password_stderr("Password: ") {
|
match prompt_password_stderr("Password: ") {
|
||||||
Ok(password) => password,
|
Ok(password) => password,
|
||||||
Err(err) => quit_error(err.context(
|
Err(err) => quit_error(err.context(
|
||||||
"Failed to read password from password prompt"
|
"failed to read password from password prompt"
|
||||||
), ErrorHints::default()),
|
), ErrorHints::default()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,7 +319,7 @@ pub fn prompt(msg: &str, main_matcher: &MainMatcher) -> String {
|
||||||
// Quit with an error if we may not interact
|
// Quit with an error if we may not interact
|
||||||
if main_matcher.no_interact() {
|
if main_matcher.no_interact() {
|
||||||
quit_error_msg(format!(
|
quit_error_msg(format!(
|
||||||
"Could not prompt for '{}' in no-interact mode, maybe specify it",
|
"could not prompt for '{}' in no-interact mode, maybe specify it",
|
||||||
msg,
|
msg,
|
||||||
), ErrorHints::default());
|
), ErrorHints::default());
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ pub fn prompt(msg: &str, main_matcher: &MainMatcher) -> String {
|
||||||
let mut input = String::new();
|
let mut input = String::new();
|
||||||
if let Err(err) = stdin().read_line(&mut input) {
|
if let Err(err) = stdin().read_line(&mut input) {
|
||||||
quit_error(err.context(
|
quit_error(err.context(
|
||||||
"Failed to read input from prompt"
|
"failed to read input from prompt"
|
||||||
), ErrorHints::default());
|
), ErrorHints::default());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ pub fn prompt_yes(
|
||||||
return def;
|
return def;
|
||||||
} else {
|
} else {
|
||||||
quit_error_msg(format!(
|
quit_error_msg(format!(
|
||||||
"Could not prompt question '{}' in no-interact mode, maybe specify it",
|
"could not prompt question '{}' in no-interact mode, maybe specify it",
|
||||||
msg,
|
msg,
|
||||||
), ErrorHints::default());
|
), ErrorHints::default());
|
||||||
}
|
}
|
||||||
|
@ -451,7 +451,7 @@ pub fn ensure_owner_token(
|
||||||
*token = Some(prompt_owner_token(main_matcher));
|
*token = Some(prompt_owner_token(main_matcher));
|
||||||
} else {
|
} else {
|
||||||
quit_error_msg(
|
quit_error_msg(
|
||||||
"Missing owner token, must be specified in no-interact mode",
|
"missing owner token, must be specified in no-interact mode",
|
||||||
ErrorHintsBuilder::default()
|
ErrorHintsBuilder::default()
|
||||||
.owner(true)
|
.owner(true)
|
||||||
.verbose(false)
|
.verbose(false)
|
||||||
|
@ -546,19 +546,20 @@ pub fn exe_name() -> String {
|
||||||
.unwrap_or(crate_name!().into())
|
.unwrap_or(crate_name!().into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check whether there is enough space avaialble at the given `path` to store a file
|
/// Ensure that there is enough free disk space available at the given `path`,
|
||||||
/// with the given `size`.
|
/// to store a file with the given `size`.
|
||||||
///
|
///
|
||||||
/// If an error occurred while querying the file system,
|
/// If an error occurred while querying the file system,
|
||||||
/// the error is reported to the user, and `true` is returned.
|
/// the error is reported to the user and the method returns.
|
||||||
///
|
///
|
||||||
/// `false` is only returned when sure that there isn't enough space available.
|
/// If there is not enough disk space available,
|
||||||
|
/// an error is reported and the program will quit.
|
||||||
pub fn ensure_enough_space<P: AsRef<Path>>(path: P, size: u64) {
|
pub fn ensure_enough_space<P: AsRef<Path>>(path: P, size: u64) {
|
||||||
// Get the available space at this path
|
// Get the available space at this path
|
||||||
let space = match available_space(path) {
|
let space = match available_space(path) {
|
||||||
Ok(space) => space,
|
Ok(space) => space,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
print_error(err.context("Failed to check available space on disk, ignoring"));
|
print_error(err.context("failed to check available space on disk, ignoring"));
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -570,15 +571,15 @@ pub fn ensure_enough_space<P: AsRef<Path>>(path: P, size: u64) {
|
||||||
|
|
||||||
// Create an info message giving details about the required space
|
// Create an info message giving details about the required space
|
||||||
let info = format!(
|
let info = format!(
|
||||||
"{} is required, but only {} is available",
|
"{} of space required, but only {} is available",
|
||||||
format_bytes(size),
|
format_bytes(size),
|
||||||
format_bytes(space),
|
format_bytes(space),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Print an descriptive error and quit
|
// Print an descriptive error and quit
|
||||||
quit_error(
|
quit_error(
|
||||||
err_msg("Not enough disk space available in the target directory")
|
err_msg("not enough disk space available in the target directory")
|
||||||
.context("Failed to download file"),
|
.context("failed to download file"),
|
||||||
ErrorHintsBuilder::default()
|
ErrorHintsBuilder::default()
|
||||||
.add_info(info)
|
.add_info(info)
|
||||||
.force(true)
|
.force(true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue