diff options
| author | Aram Drevekenin <aram@poor.dev> | 2026-01-27 15:12:52 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-27 15:12:52 +0100 |
| commit | faeb91a3e6b8053f92c459cca13a4c55abe5ae5f (patch) | |
| tree | cfa7ab91ad9fd1d8734aa832e6d494d4216e036d | |
| parent | docs(changelog): restore tab position (diff) | |
| download | sl0ppij-faeb91a3e6b8053f92c459cca13a4c55abe5ae5f.tar.gz sl0ppij-faeb91a3e6b8053f92c459cca13a4c55abe5ae5f.tar.xz sl0ppij-faeb91a3e6b8053f92c459cca13a4c55abe5ae5f.zip | |
fix: session creation time on musl (for "zellij ls") (#4645)
* fix: creation time on musl
* add pr
| -rw-r--r-- | CHANGELOG.md | 1 | ||||
| -rw-r--r-- | zellij-utils/src/sessions.rs | 17 |
2 files changed, 11 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a806c0e6..e151d242 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) * fix: properly occlude cursor in floating panes when (partially) covered by another pinned pane (https://github.com/zellij-org/zellij/pull/4644) * fix: resolve short layout names as files if possible (https://github.com/zellij-org/zellij/pull/4640) * fix: restore focused tab position on reattaching to a detached session (https://github.com/zellij-org/zellij/pull/4115) +* fix: session creation time (all session created 0s ago bug) on musl targets (https://github.com/zellij-org/zellij/pull/4645) ## [0.43.1] - 2025-08-08 diff --git a/zellij-utils/src/sessions.rs b/zellij-utils/src/sessions.rs index 9fc3ee8f..da80d5bb 100644 --- a/zellij-utils/src/sessions.rs +++ b/zellij-utils/src/sessions.rs @@ -23,9 +23,12 @@ pub fn get_sessions() -> Result<Vec<(String, Duration)>, io::ErrorKind> { files.for_each(|file| { if let Ok(file) = file { let file_name = file.file_name().into_string().unwrap(); + // try to get creation time, fall back to modification time on platforms where it's not supported (e.g., musl) + // for session creation time these are almost always identical (notable + // exceptions are session name changes) let ctime = std::fs::metadata(&file.path()) .ok() - .and_then(|f| f.created().ok()) + .and_then(|f| f.created().ok().or_else(|| f.modified().ok())) .and_then(|d| d.elapsed().ok()) .unwrap_or_default(); let duration = Duration::from_secs(ctime.as_secs()); @@ -51,12 +54,12 @@ pub fn get_resurrectable_sessions() -> Vec<(String, Duration)> { .filter_map(|folder_name| { let layout_file_name = session_layout_cache_file_name(&folder_name.display().to_string()); - let ctime = match std::fs::metadata(&layout_file_name) - .and_then(|metadata| metadata.created()) - { - Ok(created) => Some(created), - Err(_e) => None, - }; + // Try to get creation time, fall back to modification time on platforms where it's not supported (e.g., musl) + let ctime = std::fs::metadata(&layout_file_name) + .ok() + .and_then(|metadata| { + metadata.created().ok().or_else(|| metadata.modified().ok()) + }); let elapsed_duration = ctime .map(|ctime| { Duration::from_secs(ctime.elapsed().ok().unwrap_or_default().as_secs()) |
