mirror of
https://github.com/chatmail/core.git
synced 2026-05-23 00:36:32 +03:00
Stop saving and loading jobs.param column
This commit is contained in:
@@ -13,7 +13,6 @@ use crate::imap::{Imap, ImapActionResult};
|
|||||||
use crate::job::{self, Action, Job, Status};
|
use crate::job::{self, Action, Job, Status};
|
||||||
use crate::message::{Message, MsgId, Viewtype};
|
use crate::message::{Message, MsgId, Viewtype};
|
||||||
use crate::mimeparser::{MimeMessage, Part};
|
use crate::mimeparser::{MimeMessage, Part};
|
||||||
use crate::param::Params;
|
|
||||||
use crate::tools::time;
|
use crate::tools::time;
|
||||||
use crate::{job_try, stock_str, EventType};
|
use crate::{job_try, stock_str, EventType};
|
||||||
|
|
||||||
@@ -86,11 +85,7 @@ impl MsgId {
|
|||||||
DownloadState::Available | DownloadState::Failure => {
|
DownloadState::Available | DownloadState::Failure => {
|
||||||
self.update_download_state(context, DownloadState::InProgress)
|
self.update_download_state(context, DownloadState::InProgress)
|
||||||
.await?;
|
.await?;
|
||||||
job::add(
|
job::add(context, Job::new(Action::DownloadMsg, self.to_u32(), 0)).await?;
|
||||||
context,
|
|
||||||
Job::new(Action::DownloadMsg, self.to_u32(), Params::new(), 0),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
23
src/job.rs
23
src/job.rs
@@ -13,7 +13,6 @@ use rand::{thread_rng, Rng};
|
|||||||
|
|
||||||
use crate::context::Context;
|
use crate::context::Context;
|
||||||
use crate::imap::{get_folder_meaning, FolderMeaning, Imap};
|
use crate::imap::{get_folder_meaning, FolderMeaning, Imap};
|
||||||
use crate::param::Params;
|
|
||||||
use crate::scheduler::InterruptInfo;
|
use crate::scheduler::InterruptInfo;
|
||||||
use crate::tools::time;
|
use crate::tools::time;
|
||||||
|
|
||||||
@@ -77,7 +76,6 @@ pub struct Job {
|
|||||||
pub desired_timestamp: i64,
|
pub desired_timestamp: i64,
|
||||||
pub added_timestamp: i64,
|
pub added_timestamp: i64,
|
||||||
pub tries: u32,
|
pub tries: u32,
|
||||||
pub param: Params,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Job {
|
impl fmt::Display for Job {
|
||||||
@@ -87,7 +85,7 @@ impl fmt::Display for Job {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Job {
|
impl Job {
|
||||||
pub fn new(action: Action, foreign_id: u32, param: Params, delay_seconds: i64) -> Self {
|
pub fn new(action: Action, foreign_id: u32, delay_seconds: i64) -> Self {
|
||||||
let timestamp = time();
|
let timestamp = time();
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
@@ -97,7 +95,6 @@ impl Job {
|
|||||||
desired_timestamp: timestamp + delay_seconds,
|
desired_timestamp: timestamp + delay_seconds,
|
||||||
added_timestamp: timestamp,
|
added_timestamp: timestamp,
|
||||||
tries: 0,
|
tries: 0,
|
||||||
param,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,23 +124,21 @@ impl Job {
|
|||||||
context
|
context
|
||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"UPDATE jobs SET desired_timestamp=?, tries=?, param=? WHERE id=?;",
|
"UPDATE jobs SET desired_timestamp=?, tries=? WHERE id=?;",
|
||||||
paramsv![
|
paramsv![
|
||||||
self.desired_timestamp,
|
self.desired_timestamp,
|
||||||
i64::from(self.tries),
|
i64::from(self.tries),
|
||||||
self.param.to_string(),
|
|
||||||
self.job_id as i32,
|
self.job_id as i32,
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
} else {
|
} else {
|
||||||
context.sql.execute(
|
context.sql.execute(
|
||||||
"INSERT INTO jobs (added_timestamp, action, foreign_id, param, desired_timestamp) VALUES (?,?,?,?,?);",
|
"INSERT INTO jobs (added_timestamp, action, foreign_id, desired_timestamp) VALUES (?,?,?,?);",
|
||||||
paramsv![
|
paramsv![
|
||||||
self.added_timestamp,
|
self.added_timestamp,
|
||||||
self.action,
|
self.action,
|
||||||
self.foreign_id,
|
self.foreign_id,
|
||||||
self.param.to_string(),
|
|
||||||
self.desired_timestamp
|
self.desired_timestamp
|
||||||
]
|
]
|
||||||
).await?;
|
).await?;
|
||||||
@@ -297,11 +292,7 @@ fn get_backoff_time_offset(tries: u32) -> i64 {
|
|||||||
|
|
||||||
pub(crate) async fn schedule_resync(context: &Context) -> Result<()> {
|
pub(crate) async fn schedule_resync(context: &Context) -> Result<()> {
|
||||||
kill_action(context, Action::ResyncFolders).await?;
|
kill_action(context, Action::ResyncFolders).await?;
|
||||||
add(
|
add(context, Job::new(Action::ResyncFolders, 0, 0)).await?;
|
||||||
context,
|
|
||||||
Job::new(Action::ResyncFolders, 0, Params::new(), 0),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -370,7 +361,6 @@ LIMIT 1;
|
|||||||
desired_timestamp: row.get("desired_timestamp")?,
|
desired_timestamp: row.get("desired_timestamp")?,
|
||||||
added_timestamp: row.get("added_timestamp")?,
|
added_timestamp: row.get("added_timestamp")?,
|
||||||
tries: row.get("tries")?,
|
tries: row.get("tries")?,
|
||||||
param: row.get::<_, String>("param")?.parse().unwrap_or_default(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(job)
|
Ok(job)
|
||||||
@@ -410,8 +400,8 @@ mod tests {
|
|||||||
.sql
|
.sql
|
||||||
.execute(
|
.execute(
|
||||||
"INSERT INTO jobs
|
"INSERT INTO jobs
|
||||||
(added_timestamp, action, foreign_id, param, desired_timestamp)
|
(added_timestamp, action, foreign_id, desired_timestamp)
|
||||||
VALUES (?, ?, ?, ?, ?);",
|
VALUES (?, ?, ?, ?);",
|
||||||
paramsv![
|
paramsv![
|
||||||
now,
|
now,
|
||||||
if valid {
|
if valid {
|
||||||
@@ -420,7 +410,6 @@ mod tests {
|
|||||||
-1
|
-1
|
||||||
},
|
},
|
||||||
foreign_id,
|
foreign_id,
|
||||||
Params::new().to_string(),
|
|
||||||
now
|
now
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user