Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ fn startup_sync() {
};

let last_modified = FileTime::from_last_modification_time(&metadata);
let last_modified = NaiveDateTime::from_timestamp(last_modified.unix_seconds(), 0);
let last_modified: DateTime<Utc> = DateTime::from_utc(last_modified, Utc);
let last_modified = NaiveDateTime::from_timestamp_opt(last_modified.unix_seconds(), 0);
let last_modified: DateTime<Utc> = DateTime::from_utc(last_modified.unwrap(), Utc);

let uri = utils::date_to_prefix(last_modified.date())
let uri = utils::date_to_prefix(last_modified.date_naive())
+ &utils::hour_to_prefix(last_modified.hour())
+ &utils::minute_to_prefix(
last_modified.minute(),
Expand Down
2 changes: 1 addition & 1 deletion server/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ impl StorageSync {

fn move_local_to_temp(&self) -> io::Result<()> {
let time = self.time - Duration::minutes(OBJECT_STORE_DATA_GRANULARITY as i64);
let uri = utils::date_to_prefix(time.date())
let uri = utils::date_to_prefix(time.date_naive())
+ &utils::hour_to_prefix(time.hour())
+ &utils::minute_to_prefix(time.minute(), OBJECT_STORE_DATA_GRANULARITY).unwrap();
let local_uri = str::replace(&uri, "/", ".");
Expand Down
12 changes: 6 additions & 6 deletions server/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

use actix_web::web;
use chrono::{Date, DateTime, Timelike, Utc};
use chrono::{DateTime, NaiveDate, Timelike, Utc};
use serde_json::{json, Value};
use std::collections::HashMap;

Expand Down Expand Up @@ -209,7 +209,7 @@ pub fn minute_to_slot(minute: u32, data_granularity: u32) -> Option<String> {
Some(format!("{:02}-{:02}", block_start, block_end))
}

pub fn date_to_prefix(date: Date<Utc>) -> String {
pub fn date_to_prefix(date: NaiveDate) -> String {
let date = format!("date={}/", date);
date.replace("UTC", "")
}
Expand Down Expand Up @@ -247,8 +247,8 @@ impl TimePeriod {

self.generate_date_prefixes(
&prefix,
self.start.date(),
self.end.date(),
self.start.date_naive(),
self.end.date_naive(),
(self.start.hour(), self.start.minute()),
(self.end.hour(), end_minute),
)
Expand Down Expand Up @@ -341,8 +341,8 @@ impl TimePeriod {
pub fn generate_date_prefixes(
&self,
prefix: &str,
start_date: Date<Utc>,
end_date: Date<Utc>,
start_date: NaiveDate,
end_date: NaiveDate,
start_time: (u32, u32),
end_time: (u32, u32),
) -> Vec<String> {
Expand Down