diff options
| author | Dan Engelbrecht <[email protected]> | 2026-04-20 07:27:35 +0200 |
|---|---|---|
| committer | GitHub Enterprise <[email protected]> | 2026-04-20 07:27:35 +0200 |
| commit | c7c59cdc5a70bfd6e5f66f3b032ea3f8f6b4d12a (patch) | |
| tree | 8ce2472f9fbdd29a899be25adc864baf98ff8184 /src/zen/cmds/wipe_cmd.cpp | |
| parent | Merge pull request #976 from ue-foundation/zs/config-build-storage (diff) | |
| download | archived-zen-c7c59cdc5a70bfd6e5f66f3b032ea3f8f6b4d12a.tar.xz archived-zen-c7c59cdc5a70bfd6e5f66f3b032ea3f8f6b4d12a.zip | |
builds cmd refactor (#975)
- Bugfix: `builds download` partial-block fetch decisions now account for build storage host latency
- Bugfix: Transfer rate displays in `builds` commands now smooth correctly
- Split `buildstorageoperations.cpp` (8.5k lines) into per-operation TUs: buildinspect, buildprimecache, buildstorageresolve, buildupdatefolder, builduploadfolder, buildvalidatebuildpart; stats moved to buildstoragestats.h.
- FilteredRate extracted to zenutil.
- BuildsCommand shared state consolidated into a BuildsConfiguration struct; subcommands inherit from BuildsSubCmdBase holding a `const BuildsConfiguration&` instead of a `BuildsCommand&`.
- `ProgressBar` renamed to `ConsoleProgressBar`; mode enum (`ConsoleProgressMode`) lifted to namespace scope; `PushLogOperation`/`PopLogOperation`/`ForceLinebreak` promoted to virtuals on `ProgressBase`.
- Free-function wrappers (`UploadFolder`, `DownloadFolder`, `ValidateBuildPart`) added around the existing operation classes so callers stop reimplementing setup + stats logging.
Diffstat (limited to 'src/zen/cmds/wipe_cmd.cpp')
| -rw-r--r-- | src/zen/cmds/wipe_cmd.cpp | 49 |
1 files changed, 25 insertions, 24 deletions
diff --git a/src/zen/cmds/wipe_cmd.cpp b/src/zen/cmds/wipe_cmd.cpp index c027f0d67..713c5e386 100644 --- a/src/zen/cmds/wipe_cmd.cpp +++ b/src/zen/cmds/wipe_cmd.cpp @@ -12,7 +12,7 @@ #include <zencore/trace.h> #include <zenutil/workerpools.h> -#include "../progressbar.h" +#include "consoleprogress.h" #include <signal.h> @@ -35,13 +35,13 @@ ZEN_THIRD_PARTY_INCLUDES_END namespace zen { namespace wipe_impl { - static std::atomic<bool> AbortFlag = false; - static std::atomic<bool> PauseFlag = false; - static bool IsVerbose = false; - static bool Quiet = false; - static ProgressBar::Mode ProgressMode = ProgressBar::Mode::Pretty; - const bool SingleThreaded = false; - bool BoostWorkerThreads = true; + static std::atomic<bool> AbortFlag = false; + static std::atomic<bool> PauseFlag = false; + static bool IsVerbose = false; + static bool Quiet = false; + static ConsoleProgressMode ProgressMode = ConsoleProgressMode::Pretty; + const bool SingleThreaded = false; + bool BoostWorkerThreads = true; WorkerThreadPool& GetIOWorkerPool() { @@ -168,7 +168,8 @@ namespace wipe_impl { ZEN_TRACE_CPU("CleanDirectory"); Stopwatch Timer; - ProgressBar Progress(ProgressMode, "Clean Folder"); + std::unique_ptr<ProgressBase> ProgressOwner(CreateConsoleProgress(ProgressMode)); + std::unique_ptr<ProgressBase::ProgressBar> Progress = ProgressOwner->CreateProgressBar("Clean Folder"); std::atomic<bool> CleanWipe = true; std::atomic<uint64_t> DiscoveredItemCount = 0; @@ -414,7 +415,7 @@ namespace wipe_impl { GetIOWorkerPool(), Work.PendingWork()); - Work.Wait(ProgressMode == ProgressBar::Mode::Pretty ? 200 : 5000, [&](bool IsAborted, bool IsPaused, ptrdiff_t PendingWork) { + Work.Wait(ProgressOwner->GetProgressUpdateDelayMS(), [&](bool IsAborted, bool IsPaused, ptrdiff_t PendingWork) { ZEN_UNUSED(PendingWork); if (Quiet) { @@ -425,12 +426,12 @@ namespace wipe_impl { uint64_t Deleted = DeletedItemCount.load(); uint64_t DeletedBytes = DeletedByteCount.load(); uint64_t Discovered = DiscoveredItemCount.load(); - Progress.UpdateState({.Task = "Removing files ", - .Details = fmt::format("Found {}, Deleted {} ({})", Discovered, Deleted, NiceBytes(DeletedBytes)), - .TotalCount = Discovered, - .RemainingCount = Discovered - Deleted, - .Status = ProgressBar::State::CalculateStatus(IsAborted, IsPaused)}, - false); + Progress->UpdateState({.Task = "Removing files ", + .Details = fmt::format("Found {}, Deleted {} ({})", Discovered, Deleted, NiceBytes(DeletedBytes)), + .TotalCount = Discovered, + .RemainingCount = Discovered - Deleted, + .Status = ProgressBase::ProgressBar::State::CalculateStatus(IsAborted, IsPaused)}, + false); }); std::vector<std::filesystem::path> DirectoriesToDelete; @@ -474,22 +475,22 @@ namespace wipe_impl { } uint64_t NowMs = Timer.GetElapsedTimeMs(); - if ((NowMs - LastUpdateTimeMs) >= GetUpdateDelayMS(ProgressMode)) + if ((NowMs - LastUpdateTimeMs) >= ProgressOwner->GetProgressUpdateDelayMS()) { LastUpdateTimeMs = NowMs; uint64_t Deleted = DeletedItemCount.load(); uint64_t DeletedBytes = DeletedByteCount.load(); uint64_t Discovered = DiscoveredItemCount.load(); - Progress.UpdateState({.Task = "Removing folders", - .Details = fmt::format("Found {}, Deleted {} ({})", Discovered, Deleted, NiceBytes(DeletedBytes)), - .TotalCount = DirectoriesToDelete.size(), - .RemainingCount = DirectoriesToDelete.size() - SubDirectoryIndex}, - false); + Progress->UpdateState({.Task = "Removing folders", + .Details = fmt::format("Found {}, Deleted {} ({})", Discovered, Deleted, NiceBytes(DeletedBytes)), + .TotalCount = DirectoriesToDelete.size(), + .RemainingCount = DirectoriesToDelete.size() - SubDirectoryIndex}, + false); } } - Progress.Finish(); + Progress->Finish(); uint64_t ElapsedTimeMs = Timer.GetElapsedTimeMs(); if (!Quiet) @@ -549,7 +550,7 @@ WipeCommand::Run(const ZenCliOptions& GlobalOptions, int argc, char** argv) Quiet = m_Quiet; IsVerbose = m_Verbose; - ProgressMode = m_PlainProgress ? ProgressBar::Mode::Plain : ProgressBar::Mode::Pretty; + ProgressMode = m_PlainProgress ? ConsoleProgressMode::Plain : ConsoleProgressMode::Pretty; BoostWorkerThreads = m_BoostWorkerThreads; MakeSafeAbsolutePathInPlace(m_Directory); |