Skip to content

Commit

Permalink
Time
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksongoode committed Oct 19, 2024
1 parent 7f12f33 commit 117beb3
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
13 changes: 12 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions psst-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ edition = "2021"


[build-dependencies]
chrono = { version = "0.4.38" }
gix-config = { version = "0.40.0" }
time = { version = "0.3.36", features = ["local-offset"] }

[dependencies]
psst-protocol = { path = "../psst-protocol" }

# Common
byteorder = { version = "1.5.0" }
git-version = { version = "0.3.9" }
crossbeam-channel = { version = "0.5.13" }
git-version = { version = "0.3.9" }
log = { version = "0.4.22" }
num-bigint = { version = "0.4.6", features = ["rand"] }
num-traits = { version = "0.2.19" }
oauth2 = { version = "4.4.2" }
once_cell = { version = "1.19.0" }
parking_lot = { version = "0.12.3" }
quick-protobuf = { version = "0.8.1" }
Expand All @@ -30,7 +31,6 @@ socks = { version = "0.3.4" }
tempfile = { version = "3.12.0" }
ureq = { version = "2.10.1", features = ["json"] }
url = { version = "2.5.2" }
oauth2 = { version = "4.4.2" }

# Cryptography
aes = { version = "0.8.4" }
Expand All @@ -45,7 +45,13 @@ cpal = { version = "0.15.3", optional = true }
cubeb = { git = "https://github.com/mozilla/cubeb-rs", optional = true }
libsamplerate = { version = "0.1.0" }
rb = { version = "0.4.1" }
symphonia = { version = "0.5.4", default-features = false, features = ["ogg", "vorbis", "mp3"]}
symphonia = { version = "0.5.4", default-features = false, features = [
"ogg",
"vorbis",
"mp3",
] }

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.58.0", features = ["Win32_System_Com"], default-features = false }
windows = { version = "0.58.0", features = [
"Win32_System_Com",
], default-features = false }
8 changes: 5 additions & 3 deletions psst-core/build.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use gix_config::File;
use std::{env, fs, io::Write};
use time::OffsetDateTime;

fn main() {
let outdir = env::var("OUT_DIR").unwrap();
let outfile = format!("{}/build-time.txt", outdir);

let mut fh = fs::File::create(outfile).unwrap();
write!(fh, r#""{}""#, chrono::Local::now()).ok();
let now = OffsetDateTime::now_local().unwrap_or_else(|_| OffsetDateTime::now_utc());
write!(fh, r#""{}""#, now).ok();

let git_config =
gix_config::File::from_git_dir("../.git/".into()).expect("Git Config not found!");
let git_config = File::from_git_dir("../.git/".into()).expect("Git Config not found!");
// Get Git's 'Origin' URL
let mut remote_url = git_config
.raw_value("remote.origin.url")
Expand Down
27 changes: 9 additions & 18 deletions psst-gui/src/data/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::{
#[cfg(target_family = "unix")]
use std::os::unix::fs::OpenOptionsExt;

use druid::{Data, Lens, Size};
use directories::ProjectDirs;
use druid::{Data, Lens, Size};
use psst_core::{
cache::mkdir_if_not_exists,
connection::Credentials,
Expand Down Expand Up @@ -282,23 +282,14 @@ impl Default for SortCriteria {
}
}

// Add this function at the end of the file
fn get_dir_size(path: &Path) -> Option<u64> {
let mut total_size = 0;
if let Ok(entries) = fs::read_dir(path) {
for entry in entries.flatten() {
if let Ok(metadata) = entry.metadata() {
if metadata.is_file() {
total_size += metadata.len();
} else if metadata.is_dir() {
if let Some(size) = get_dir_size(&entry.path()) {
total_size += size;
}
}
}
}
Some(total_size)
fs::read_dir(path).ok()?.fold(Some(0), |acc, entry| {
let entry = entry.ok()?;
let size = if entry.file_type().ok()?.is_dir() {
get_dir_size(&entry.path())?
} else {
None
}
entry.metadata().ok()?.len()
};
acc.map(|total| total + size)
})
}
7 changes: 4 additions & 3 deletions psst-gui/src/ui/lyrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ fn track_lyrics_widget() -> impl Widget<AppState> {
.on_left_click(|ctx, _, c, _| {
if c.data.start_time_ms.parse::<u64>().unwrap() != 0 {
ctx.submit_command(
cmd::SKIP_TO_POSITION.with(c.data.start_time_ms.parse::<u64>().unwrap())
cmd::SKIP_TO_POSITION
.with(c.data.start_time_ms.parse::<u64>().unwrap()),
)
}
}
})
})
},
Expand All @@ -92,4 +93,4 @@ fn track_lyrics_widget() -> impl Widget<AppState> {
|_, data, _| data.lyrics.defer(()),
|_, data, r| data.lyrics.update(((), r.1)),
)
}
}

0 comments on commit 117beb3

Please sign in to comment.