fix incorrect path and cut a new release #21
6 changed files with 31 additions and 13 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1204,7 +1204,7 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "jobboerse"
|
name = "jobboerse"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"actix-files",
|
"actix-files",
|
||||||
"actix-multipart",
|
"actix-multipart",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "jobboerse"
|
name = "jobboerse"
|
||||||
version = "0.1.3"
|
version = "0.1.4"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.58"
|
rust-version = "1.58"
|
||||||
repository = "https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse"
|
repository = "https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse"
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.1.4] (2022-05-25)
|
||||||
|
|
||||||
|
### Fix
|
||||||
|
- replace incorrectly hardcoded path by config value
|
||||||
|
|
||||||
## [0.1.3] (2022-05-25)
|
## [0.1.3] (2022-05-25)
|
||||||
|
|
||||||
### Add
|
### Add
|
||||||
|
|
@ -52,6 +57,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
- Overview Page of Dependency licenses
|
- Overview Page of Dependency licenses
|
||||||
|
|
||||||
[Unreleased]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/main
|
[Unreleased]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/main
|
||||||
|
[0.1.4]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.4
|
||||||
[0.1.3]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.3
|
[0.1.3]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.3
|
||||||
[0.1.2]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.2
|
[0.1.2]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.2
|
||||||
[0.1.1]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.1
|
[0.1.1]: https://www.fs-infmath.uni-kiel.de/git/FS-InfMath/Jobboerse/src/version-0.1.1
|
||||||
|
|
|
||||||
2
dist/arch/PKGBUILD
vendored
2
dist/arch/PKGBUILD
vendored
|
|
@ -9,7 +9,7 @@ _reponame=Jobboerse
|
||||||
_pkgname="${_reponame,,}"
|
_pkgname="${_reponame,,}"
|
||||||
_features=()
|
_features=()
|
||||||
pkgname="${_reponame,,}"
|
pkgname="${_reponame,,}"
|
||||||
pkgver=0.1.3
|
pkgver=0.1.4
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
pkgdesc="FS-InfMath Job-Offer Page"
|
pkgdesc="FS-InfMath Job-Offer Page"
|
||||||
arch=('x86_64') # Other architectures may work
|
arch=('x86_64') # Other architectures may work
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use futures_util::StreamExt;
|
||||||
use handlebars::Handlebars;
|
use handlebars::Handlebars;
|
||||||
use lettre::message::{Mailbox, SinglePart};
|
use lettre::message::{Mailbox, SinglePart};
|
||||||
use lettre::{Address, AsyncTransport};
|
use lettre::{Address, AsyncTransport};
|
||||||
use log::{debug, warn};
|
use log::{debug, error, warn};
|
||||||
use rand::distributions::DistString;
|
use rand::distributions::DistString;
|
||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
@ -87,7 +87,7 @@ pub(crate) async fn create_joboffer_post(
|
||||||
debug!("got lease, starting to process submission");
|
debug!("got lease, starting to process submission");
|
||||||
|
|
||||||
let job_offer_form =
|
let job_offer_form =
|
||||||
match JobOfferSubmitForm::from_multipart_form(multipart, user.as_ref()).await {
|
match JobOfferSubmitForm::from_multipart_form(multipart, user.as_ref(), &config).await {
|
||||||
Ok(form) => form,
|
Ok(form) => form,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if let Some(lease) = submission_lease {
|
if let Some(lease) = submission_lease {
|
||||||
|
|
@ -261,6 +261,7 @@ impl JobOfferSubmitForm {
|
||||||
async fn from_multipart_form(
|
async fn from_multipart_form(
|
||||||
mut multipart: Multipart,
|
mut multipart: Multipart,
|
||||||
user: Option<&User>,
|
user: Option<&User>,
|
||||||
|
config: &ServerConfig,
|
||||||
) -> Result<Self, MultipartFieldError> {
|
) -> Result<Self, MultipartFieldError> {
|
||||||
let mut title = None;
|
let mut title = None;
|
||||||
let mut offering_party = None;
|
let mut offering_party = None;
|
||||||
|
|
@ -349,14 +350,20 @@ impl JobOfferSubmitForm {
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
ATTACHMENT_FILES => {
|
ATTACHMENT_FILES => {
|
||||||
multi_file(
|
let result = multi_file(
|
||||||
field,
|
field,
|
||||||
ATTACHMENT_FILES,
|
ATTACHMENT_FILES,
|
||||||
&mut attachment_datas,
|
&mut attachment_datas,
|
||||||
upload_size_limit,
|
upload_size_limit,
|
||||||
upload_count_limit,
|
upload_count_limit,
|
||||||
|
config,
|
||||||
)
|
)
|
||||||
.await?
|
.await;
|
||||||
|
|
||||||
|
if let Err(err) = result {
|
||||||
|
error!("Failed to process file upload {:?}", err);
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LINK_TITLES => {
|
LINK_TITLES => {
|
||||||
multi_field(field, LINK_TITLES, &mut link_titles, 128, Some(20)).await?
|
multi_field(field, LINK_TITLES, &mut link_titles, 128, Some(20)).await?
|
||||||
|
|
@ -399,6 +406,7 @@ impl JobOfferSubmitForm {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
assert_eq!(link_titles.len(), link_urls.len());
|
assert_eq!(link_titles.len(), link_urls.len());
|
||||||
|
|
||||||
let links = link_titles
|
let links = link_titles
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.zip(link_urls.into_iter())
|
.zip(link_urls.into_iter())
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ use futures_util::StreamExt;
|
||||||
use tempfile::NamedTempFile;
|
use tempfile::NamedTempFile;
|
||||||
|
|
||||||
use crate::error::MultipartFieldError;
|
use crate::error::MultipartFieldError;
|
||||||
|
use crate::ServerConfig;
|
||||||
|
|
||||||
pub async fn once_field(
|
pub async fn once_field(
|
||||||
field: Field,
|
field: Field,
|
||||||
|
|
@ -45,11 +46,12 @@ pub async fn multi_field(
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
pub async fn once_file(
|
pub(crate) async fn once_file(
|
||||||
field: Field,
|
field: Field,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
storage: &mut Option<(String, Option<NamedTempFile>)>,
|
storage: &mut Option<(String, Option<NamedTempFile>)>,
|
||||||
max_size: usize,
|
max_size: usize,
|
||||||
|
config: &ServerConfig,
|
||||||
) -> Result<(), MultipartFieldError> {
|
) -> Result<(), MultipartFieldError> {
|
||||||
if storage.is_some() {
|
if storage.is_some() {
|
||||||
Err(MultipartFieldError::TooManyOccurrences {
|
Err(MultipartFieldError::TooManyOccurrences {
|
||||||
|
|
@ -57,18 +59,19 @@ pub async fn once_file(
|
||||||
limit: 1,
|
limit: 1,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
let value = tmpfile_from_field(field, name, max_size).await?;
|
let value = tmpfile_from_field(field, name, max_size, config).await?;
|
||||||
*storage = Some(value);
|
*storage = Some(value);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn multi_file(
|
pub(crate) async fn multi_file(
|
||||||
field: Field,
|
field: Field,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
storage: &mut Vec<(String, Option<NamedTempFile>)>,
|
storage: &mut Vec<(String, Option<NamedTempFile>)>,
|
||||||
max_size: usize,
|
max_size: usize,
|
||||||
max_count: Option<u8>,
|
max_count: Option<u8>,
|
||||||
|
config: &ServerConfig,
|
||||||
) -> Result<(), MultipartFieldError> {
|
) -> Result<(), MultipartFieldError> {
|
||||||
if let Some(count) = max_count {
|
if let Some(count) = max_count {
|
||||||
if storage.len() >= count.into() {
|
if storage.len() >= count.into() {
|
||||||
|
|
@ -78,15 +81,16 @@ pub async fn multi_file(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let value = tmpfile_from_field(field, name, max_size).await?;
|
let value = tmpfile_from_field(field, name, max_size, config).await?;
|
||||||
storage.push(value);
|
storage.push(value);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn tmpfile_from_field(
|
pub(crate) async fn tmpfile_from_field(
|
||||||
mut field: Field,
|
mut field: Field,
|
||||||
field_name: &'static str,
|
field_name: &'static str,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
config: &ServerConfig,
|
||||||
) -> Result<(String, Option<NamedTempFile>), MultipartFieldError> {
|
) -> Result<(String, Option<NamedTempFile>), MultipartFieldError> {
|
||||||
let file_name = field
|
let file_name = field
|
||||||
.content_disposition()
|
.content_disposition()
|
||||||
|
|
@ -106,7 +110,7 @@ pub async fn tmpfile_from_field(
|
||||||
let buf = if let Some(buf) = file_buffer.as_mut() {
|
let buf = if let Some(buf) = file_buffer.as_mut() {
|
||||||
buf
|
buf
|
||||||
} else {
|
} else {
|
||||||
let file = NamedTempFile::new_in("job_offers")?;
|
let file = NamedTempFile::new_in(&config.config.data_storage_path)?;
|
||||||
file_buffer.insert(BufWriter::new(file))
|
file_buffer.insert(BufWriter::new(file))
|
||||||
};
|
};
|
||||||
remaining -= data.len();
|
remaining -= data.len();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue