From 461552b8d0a714d3e931c6cf3bf389e8746c46c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Fri, 16 Jan 2026 20:02:03 +0800 Subject: [PATCH] DynamicInterval: reruns `prepare` code before next interval Fixes #2152 --- src/detection/cpuusage/cpuusage.c | 3 ++- src/detection/diskio/diskio.c | 2 ++ src/detection/netio/netio.c | 2 ++ src/fastfetch.c | 5 +++++ src/logo/logo.c | 2 +- 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/detection/cpuusage/cpuusage.c b/src/detection/cpuusage/cpuusage.c index 40e569528..72393aa45 100644 --- a/src/detection/cpuusage/cpuusage.c +++ b/src/detection/cpuusage/cpuusage.c @@ -9,7 +9,8 @@ static uint64_t startTime; void ffPrepareCPUUsage(void) { - assert(cpuTimes1.elementSize == 0); + if (cpuTimes1.elementSize != 0) return; // Already prepared + ffListInit(&cpuTimes1, sizeof(FFCpuUsageInfo)); ffGetCpuUsageInfo(&cpuTimes1); startTime = ffTimeGetNow(); diff --git a/src/detection/diskio/diskio.c b/src/detection/diskio/diskio.c index 9413a7125..00f7bc244 100644 --- a/src/detection/diskio/diskio.c +++ b/src/detection/diskio/diskio.c @@ -11,6 +11,8 @@ void ffPrepareDiskIO(FFDiskIOOptions* options) { if (options->detectTotal) return; + if (time1 != 0) return; // Already prepared + ffListInit(&ioCounters1, sizeof(FFDiskIOResult)); ffDiskIOGetIoCounters(&ioCounters1, options); time1 = ffTimeGetNow(); diff --git a/src/detection/netio/netio.c b/src/detection/netio/netio.c index 666321c99..48d6ba7b1 100644 --- a/src/detection/netio/netio.c +++ b/src/detection/netio/netio.c @@ -9,6 +9,8 @@ void ffPrepareNetIO(FFNetIOOptions* options) { if (options->detectTotal) return; + if (time1 != 0) return; // Already prepared + ffListInit(&ioCounters1, sizeof(FFNetIOResult)); ffNetIOGetIoCounters(&ioCounters1, options); time1 = ffTimeGetNow(); diff --git a/src/fastfetch.c b/src/fastfetch.c index d0882b15e..60df8051f 100644 --- a/src/fastfetch.c +++ b/src/fastfetch.c @@ -811,6 +811,11 @@ static void run(FFdata* data) } else break; + + if (useJsonConfig) + ffPrintJsonConfig(data, true /* prepare */); + else + ffPrepareCommandOption(data); } if (data->resultDoc) diff --git a/src/logo/logo.c b/src/logo/logo.c index 2f009adc0..1bd6cb8e9 100644 --- a/src/logo/logo.c +++ b/src/logo/logo.c @@ -702,7 +702,7 @@ void ffLogoPrintLine(void) printf("\033[%uC", instance.state.logoWidth); if (instance.state.dynamicInterval > 0) - fputs("\033[K", stdout); + fputs("\033[K", stdout); // Clear to the end of the line ++instance.state.keysHeight; }