mirror of
https://github.com/lifegpc/pixiv_downloader.git
synced 2026-07-08 01:32:41 +08:00
Impl Send for UgoiraError2
This commit is contained in:
@@ -7,7 +7,6 @@ use crate::data::json::JSONDataFile;
|
||||
#[cfg(feature = "ugoira")]
|
||||
use crate::data::video::get_video_metadata;
|
||||
use crate::downloader::Downloader;
|
||||
use crate::downloader::DownloaderError;
|
||||
use crate::downloader::DownloaderResult;
|
||||
use crate::downloader::LocalFile;
|
||||
use crate::error::PixivDownloaderError;
|
||||
@@ -72,7 +71,7 @@ impl Main {
|
||||
/// * `progress_bars` - Multiple progress bars
|
||||
/// * `datas` - The artwork's data
|
||||
/// * `base` - The directory of the target
|
||||
pub async fn download_artwork_link<L: IntoUrl + Clone>(link: L, np: u16, progress_bars: Option<Arc<MultiProgress>>, datas: Arc<PixivData>, base: Arc<PathBuf>) -> Result<(), DownloaderError> {
|
||||
pub async fn download_artwork_link<L: IntoUrl + Clone>(link: L, np: u16, progress_bars: Option<Arc<MultiProgress>>, datas: Arc<PixivData>, base: Arc<PathBuf>) -> Result<(), PixivDownloaderError> {
|
||||
let file_name = get_file_name_from_url(link.clone()).try_err(format!("{} {}", gettext("Failed to get file name from url:"), link.as_str()))?;
|
||||
let file_name = base.join(file_name);
|
||||
let helper = get_helper();
|
||||
@@ -239,14 +238,7 @@ impl Main {
|
||||
for task in tasks {
|
||||
let r = spin_on(task);
|
||||
let r = match r {
|
||||
Ok(r) => {
|
||||
match r {
|
||||
Ok(o) => { Ok(o) }
|
||||
Err(e) => {
|
||||
Err(PixivDownloaderError::from(e))
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(r) => { r }
|
||||
Err(e) => {
|
||||
Err(PixivDownloaderError::from(e))
|
||||
}
|
||||
|
||||
@@ -246,6 +246,8 @@ impl PartialEq for UgoiraZipError2 {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl Send for UgoiraZipError2 {}
|
||||
|
||||
impl ToRawHandle<_ugoira::zip_error_t> for UgoiraZipError2 {
|
||||
unsafe fn to_raw_handle(&self) -> *mut _ugoira::zip_error_t {
|
||||
self.err
|
||||
@@ -362,6 +364,22 @@ pub fn convert_ugoira_to_mp4<S: AsRef<OsStr> + ?Sized, D: AsRef<OsStr> + ?Sized,
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
async fn get_ugoira_zip_error2() -> UgoiraZipError2 {
|
||||
let ugo = unsafe { _ugoira::new_ugoira_error() };
|
||||
if ugo.is_null() {
|
||||
panic!("Out of memory.");
|
||||
}
|
||||
UgoiraZipError2 { err: ugo }
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_ugoira_zip_error2() {
|
||||
let task = tokio::spawn(get_ugoira_zip_error2());
|
||||
let re = task.await.unwrap();
|
||||
assert!(re.to_str().is_ok())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_ugoira_frames() {
|
||||
let mut f = UgoiraFrames::new();
|
||||
|
||||
@@ -489,6 +489,16 @@ void ugoira_mfree(void* data) {
|
||||
if (data) free(data);
|
||||
}
|
||||
|
||||
zip_error_t* new_ugoira_error() {
|
||||
zip_error_t* err = malloc(sizeof(zip_error_t));
|
||||
if (!err) {
|
||||
return NULL;
|
||||
}
|
||||
memset(err, 0, sizeof(zip_error_t));
|
||||
zip_error_init(err);
|
||||
return err;
|
||||
}
|
||||
|
||||
void free_ugoira_error(zip_error_t* zip_err) {
|
||||
if (!zip_err) return;
|
||||
zip_error_fini(zip_err);
|
||||
|
||||
@@ -41,6 +41,7 @@ void free_ugoira_frames(UgoiraFrame* frames);
|
||||
UgoiraError convert_ugoira_to_mp4(const char* src, const char* dest, const UgoiraFrame* frames, float max_fps, const AVDictionary* opts, const AVDictionary* metadata);
|
||||
char* ugoira_get_zip_err_msg(int code);
|
||||
void ugoira_mfree(void* data);
|
||||
zip_error_t* new_ugoira_error();
|
||||
void free_ugoira_error(zip_error_t* zip_err);
|
||||
char* ugoira_get_zip_err2_msg(zip_error_t* zip_err2);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user