Skip to content

Commit

Permalink
Adds checkout task
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerboa-app committed May 30, 2024
1 parent a7317f6 commit 3d7bbbe
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/integrations/git/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ impl GitRefreshTask
{
pub fn new
(
lock: Arc<Mutex<()>>,
schedule: Option<Schedule>
) -> GitRefreshTask
{
GitRefreshTask
{
lock: Arc::new(Mutex::new(())),
lock,
last_run: chrono::offset::Utc::now(),
next_run: if schedule.is_none() { None } else { next_job_time(schedule.clone().unwrap()) },
schedule
Expand Down
4 changes: 0 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ const MAJOR: &str = env!("CARGO_PKG_VERSION_MAJOR");
const MINOR: &str = env!("CARGO_PKG_VERSION_MINOR");
const PATCH: &str = env!("CARGO_PKG_VERSION_PATCH");

const RESOURCE_REGEX: &str = r"(\.\S+)";
const HTML_REGEX: &str = r"(\.html)$";
const NO_EXTENSION_REGEX: &str = r"^(?!.*\.).*";

const CRAB: [u8; 4] = [0xF0, 0x9F, 0xA6, 0x80];
const BLAZING: [u8; 4] = [0xF0, 0x9F, 0x94, 0xA5];

Expand Down
21 changes: 20 additions & 1 deletion src/server/https.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::
{
config::{read_config, Config, CONFIG_PATH}, content::sitemap::SiteMap, server::throttle::{handle_throttle, IpThrottler}, task::{schedule_from_option, TaskPool}, CRAB
config::{read_config, Config, CONFIG_PATH}, content::sitemap::SiteMap, integrations::git::refresh::GitRefreshTask, server::throttle::{handle_throttle, IpThrottler}, task::{schedule_from_option, TaskPool}, CRAB
};

use core::time;
Expand All @@ -26,6 +26,7 @@ pub struct Server
router: Router,
config: Config,
handle: Handle,
repo_mutex: Arc<Mutex<()>>,
pub tasks: TaskPool
}

Expand Down Expand Up @@ -88,12 +89,15 @@ impl Server

router = router.layer(middleware::from_fn_with_state(Some(stats.clone()), StatsDigest::filter));

let repo_mutex = Arc::new(Mutex::new(()));

let mut server = Server
{
addr: SocketAddr::new(IpAddr::V4(Ipv4Addr::new(a,b,c,d)), config.port_https),
router,
config: config.clone(),
handle: Handle::new(),
repo_mutex: repo_mutex.clone(),
tasks: TaskPool::new()
};

Expand Down Expand Up @@ -121,6 +125,21 @@ impl Server
)
);

if config.git.is_some()
{
server.tasks.add
(
Box::new
(
GitRefreshTask::new
(
repo_mutex,
schedule_from_option(config.git.unwrap().checkout_schedule)
)
)
);
}

server
}

Expand Down
1 change: 0 additions & 1 deletion tests/test_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod test_stats_graph

use busser::{config::Config, filesystem::file::File, server::stats::{digest::{hits_by_hour_text_graph, process_hits, Digest}, file::StatsFile, hits::{collect_hits, Hit, HitStats}}};
use chrono::DateTime;
use openssl::conf;

const GRAPH: &str = r#"00:00
01:00-
Expand Down

0 comments on commit 3d7bbbe

Please sign in to comment.