diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..905883c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,15 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = space +indent_size = 4 + +[*.{xaml,csproj,props,slnx,json,yml,yaml,svg}] +indent_size = 2 + +[*.md] +trim_trailing_whitespace = false diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d208e41 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto eol=lf +*.ico binary +*.png binary diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..242a7c5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,19 @@ +--- +name: Bug report +about: Something went wrong while using ZipXP +labels: bug +--- + +**What happened?** + +**What did you expect?** + +**Steps to reproduce** + +**Environment** +- ZipXP version or git commit: +- Windows version: +- Drive/NTFS details if relevant (cluster size, SSD/HDD): + +**Diagnostics** +Use Activity > Copy diagnostics and paste it here. Remove any paths you do not want to share. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..92229fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,9 @@ +--- +name: Feature request +about: Suggest an improvement +labels: enhancement +--- + +**What problem would this solve?** + +**What would you like ZipXP to do?** diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..e14f962 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,6 @@ +## What and why + +## How it was checked +- [ ] `dotnet build ZipXP.slnx` has no warnings +- [ ] `scripts/check.ps1` passes (or explain why not) +- [ ] User-facing text and docs updated if behaviour changed diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..e6dfc72 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: build + +on: + push: + branches: [main] + pull_request: + +permissions: + contents: read + +jobs: + build-and-check: + runs-on: windows-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-dotnet@v4 + with: + dotnet-version: 10.0.x + - name: Build + run: dotnet build ZipXP.slnx --nologo -warnaserror + - name: Run checks + run: dotnet run --project tests/ZipXP.Checks/ZipXP.Checks.csproj --no-build diff --git a/.gitignore b/.gitignore index d533a2a..d10f9c0 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,4 @@ **/obj/ .vs/ *.user -gui/artifacts/ -storage-manager/artifacts/ +artifacts/ diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..b06bc03 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,29 @@ +# Changelog + +All notable changes to ZipXP are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). + +## [Unreleased] + +### Known issues +- After decompression, the measured allocation can be read before the file handle is closed, which overstates growth for some non-aligned file sizes and can show a small negative savings total. Tracked in [#2](https://github.com/kiranscript/zipxp/issues/2); details in [docs/validation.md](docs/validation.md). + +### Changed +- Repository reorganised into `src/`, `tests/`, `scripts/` and `docs/`; projects renamed from `StorageManager.*` to `ZipXP.*`. +- The window, tray icon and sidebar now say "ZipXP" instead of "ZipXP Storage Manager". +- README rewritten as a product front page; the technical detail moved to `docs/`. +- Added MIT license, solution file, `.editorconfig`, CI workflow and issue/PR templates. + +### Unchanged on purpose +- Data folder, startup entry, single-instance name, executable name and install folder keep their `StorageManager` identifiers so existing installs and saved policies continue to work. + +## [0.2.0] (pre-release) + +### Added +- Selective, policy-driven NTFS compression of managed folders: read-only analysis first, then optional automatic compression of existing, new, copied-in and changed files. +- Persistent single-file-at-a-time queue with retry/backoff, quiet periods, cooldowns, schedules, battery, CPU and free-space gates, and crash recovery. +- System-tray worker, optional start at sign-in, and **Restore original size** decompression. +- Overview, managed folders, storage insights and searchable activity views with a signed (+/-) allocation ledger. +- Self-contained publish package plus per-user install and uninstall scripts. + +### Removed +- The earlier file-explorer alpha. diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..e709f6c --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,15 @@ + + + net10.0-windows + enable + enable + true + 0.2.0 + ZipXP + kiran kumar + Copyright (c) 2026 kiran kumar + ZipXP: a solution to shortage of disk space. It shrinks files in place with Windows NTFS compression. + https://github.com/kiranscript/zipxp + + + diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..f028791 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2026 kiran kumar + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index 66368f6..86dc3c0 100644 --- a/README.md +++ b/README.md @@ -1,133 +1,83 @@ -# ZipXP Storage Manager +

+ ZipXP +

-The storage-management implementation of [plan.md](../plan.md), the earlier file-explorer alpha has been removed from this repository. Windows 11, C# / WPF, .NET 10, ordinary NTFS compression. Files keep their original names and paths. +

ZipXP

-## Run from WSL +

Solution to shortage of disk space.

-From the repository root: +

+ ZipXP shrinks the files you already have, in place, using Windows' built-in NTFS compression.
+ Same names. Same folders. Nothing deleted. +

-```bash -./storage-manager/run-wsl.sh -``` - -This launches the native Windows desktop app using Windows `dotnet.exe`. It looks on PATH, in `C:\Program Files\dotnet`, and in the local `C:\Temp\zipxp-dotnet` SDK used for development. Set `WINDOWS_DOTNET_EXE` to another executable's WSL path if needed. A Linux SDK cannot run WPF. - -From Windows PowerShell in `storage-manager/`: - -```powershell -dotnet run --project StorageManager.App/StorageManager.App.csproj -``` - -## Use it - -1. Select **Managed folders → Add folder…**. Choose a local fixed NTFS folder, such as `C:\Users\kiran\zipxp-test`. Adding a folder starts read-only analysis. A WSL/UNC folder is not supported. -2. Inspect the overview and storage insights. Folder rows show their policy, known logical/allocation totals, candidate bytes, status, scan time, and native directory-default count. Double-click a folder in Insights to drill down, or choose **Largest files**. -3. Select **Folder settings** and turn on automatic compression. Subfolder inclusion and battery behavior are on the first screen; file exclusions, size/benefit thresholds, quiet period, cooldown, schedule, and free-space reserve are under **Advanced options**. Previously: exclusions, quiet period, size/benefit thresholds, cooldown, schedule, battery behavior, and free-space reserve. -4. Eligible existing files are queued. New, copied-in, replaced, and changed files are discovered through notifications and periodic scans. The recommended quiet period is 60 seconds; reconciliation runs every two minutes. Busy files retry with backoff. Poor-benefit files stay excluded until their content fingerprint changes or a failed job is explicitly retried. -5. Close the window to keep the tray worker running. Reopen it from the tray. **Start when I sign in** explicitly registers this user's current launch command. **Pause all** / **Pause folder** stops new operations after the current one. **Quit ZipXP** (finishes the file in progress, then) ends the worker and leaves pending work persisted. -6. Use Activity to search/filter outcomes, copy diagnostics, and retry selected failures. Retry does not re-enable disabled automatic policies. - -Adding a folder for analysis does not compress it. **Compress now** is an explicit one-off job; it does not turn on future automation. Each recursive action shows a scope preview first. Ordinary automatic files have no per-file confirmation dialog. - -### Decompression and stopping management - -- **Restore original size…** (Overview for all folders, Managed folders toolbar per folder, or Storage insights for selected files) uncompresses files so they take their full space again; no files are deleted. It first disables automatic compression for that managed root and cancels pending compression. Re-enabling automation while decompression is pending is rejected. -- Decompression does not clear existing NTFS directory defaults. The preview reports those defaults, incomplete coverage, omitted entries, and the largest sequential operation's required headroom. -- **Turn off Windows' own folder compression** (More menu; formerly "Clear native defaults") is a separate recursive directory-only job within the current policy scope. Existing files stay compressed. Excluded/unreadable/unsupported directories may retain defaults; inspect the next scan. -- **Stop managing this folder** (More menu) removes the root, observations, and future jobs. Existing files and native defaults remain unchanged. Historical job measurements are retained. -- Resuming/pausing the selective worker does not change any native directory inheritance settings. Such defaults can compress future files even while the app is closed and can bypass the selective worker's exclusions and size limits. - -## What is implemented - -- Recursive managed roots with overlap rejection, policy exclusions, no reparse-point traversal, partial scans, and independent read-only analysis. -- A persistent single sequential queue, stable volume/file identities, fresh metadata validation, native handle-based compression, retry/backoff, cancellation between files, and crash reconciliation. -- Automatic existing/new/copied/replaced-file processing, watcher error reconciliation, quiet periods, cooldowns, and poor-result caching. -- Folder schedules (local hours, including overnight), battery control, free-space reserves, and pausing new file operations above 85% sampled total system CPU usage. These are gates between operations, not hard resource caps. -- One below-normal-priority per-user process with a tray, a single-instance activation event, optional sign-in registration, and graceful exit. No service or elevation is needed. -- Overview cards, live volume usage, managed-folder policies/status, largest-file/folder drill-down, scan allocation history, searchable activity, retry, and copyable diagnostics. -- SQLite schema migrations, local observations/jobs/settings, a daily signed allocation ledger that survives detailed-history pruning, and bounded retention. -- A WSL launcher, Windows service/UI checks, self-contained publishing, optional certificate signing, and per-user install/uninstall scripts. - -## Storage accounting - -All file measurements cover the primary data stream. Directory metadata and named streams are excluded. Unknown sizes display a dash. Scans deduplicate observed hard links within a root; the overview deduplicates known file identities across managed roots. Excluded subtrees are outside the policy scope. +

+ MIT license · + Changelog · + Docs +

-The UI keeps four different quantities separate: +> **Status: pre-release (0.2).** ZipXP is under active development and the build is unsigned. Try it on a folder of copies first. See [Safety](docs/safety.md). -1. **Volume usage/free space:** current drive statistics, including activity from all applications. -2. **Managed allocation:** known primary-stream allocations from each root's latest scan, with scan timestamps and unknown-entry coverage. This is not an atomic volume snapshot. -3. **Estimated opportunity:** three 32 KiB Deflate samples per eligible file, scaled as a heuristic. NTFS uses a different compression algorithm; the estimate is not a promise. Sampling does not mutate files. -4. **Net measured reduction:** signed `before allocation - after allocation` for successful operations with stable identity, length, and last-write time. Zero is valid; decompression growth is negative. Already-compressed/interrupted/unmeasured jobs claim no new bytes. The ledger records each completed job once and survives restart. Period filtering uses UTC days. It is a historical operation total, not a claim of current free-space recovery or savings remaining after deletion. +

+ ZipXP overview showing 74.1 MB saved, 54% less space used +

+

ZipXP after compressing a sample work folder (logs, CSV, JSON and source files; photos are skipped). The sample data is generated text, so your savings will differ.

-The history chart plots scan allocations for the selected root and period, at actual scan times. Amber bars indicate incomplete/unknown coverage; timestamps without a scan have no bar. It includes up to 32 recent scans in the period. Detailed jobs show at most 1,000 matching recent rows; up to 10,000 terminal records and 2,000 scan summaries are retained. Ledger totals are separate from that retention. +## Why ZipXP -## Filesystem and resource boundaries +- **Your files stay put.** No archives, no new formats, no changed paths. Apps open compressed files as normal. +- **It looks before it acts.** Adding a folder only analyses it and shows how much space might be saved. Nothing changes until you turn compression on. +- **It works quietly.** A small tray app compresses files in the background, one at a time, at low priority. It waits while you are on battery, the CPU is busy or the disk is nearly full. +- **It is reversible.** **Restore original size** decompresses the files ZipXP manages so they use their full space again. Nothing is deleted. Some files are never touched; see [Safety](docs/safety.md). +- **It stays on your PC.** No account, no cloud, no telemetry upload. -- Local fixed NTFS with file-compression support; no drive-root management, Windows/Program Files locations, UNC/device paths, WSL filesystem roots, or reparse-point ancestors/children. -- Hidden/system, encrypted, sparse, offline/recall, read-only, multiple-hard-link files, and unsupported entries are excluded from mutation. Inspection/access errors are visible rather than silently counted as zero. -- Initial tested manual/automatic compression sizes are 64 KiB–256 MiB. Decompression can include smaller compressed files, up to the policy's tested maximum. Policies cannot enlarge that maximum yet. -- Reserve is at least 256 MiB for compression, and full logical size plus reserve for decompression. The queue waits for space rather than filling a disk in a test. The OS may still reject a previously checked operation. -- Mutation opens one original file handle with no write/delete sharing, checks the resolved path and stable identity, validates content metadata, invokes `FSCTL_SET_COMPRESSION`, and reads back actual state/allocation from that same handle. A replacement or changed file is skipped for a rescan. Existing writers may cause a retryable sharing violation. -- Normal cancellation does not kill in-flight native I/O. Only one file mutation runs at a time, with a 500 ms worker interval. Scanning is sequential, bounded to 100,000 observations per root; automatic event-triggered rescans are spaced by at least 15 seconds. The queue holds at most 2,000 active jobs and refills through reconciliation. -- Very large roots should be split into smaller nonoverlapping managed scopes. Scans reaching the observation bound explicitly report incomplete coverage; this build does not provide resumable pagination past that bound. -- Native operations, file identity checks, and sharing restrictions improve race handling but are not a production data-integrity guarantee against every concurrent filesystem change. Use disposable copies until broader acceptance is complete. -- No recursive deletion/cleanup, deduplication mutation, cloud/network support, WOF, archive replacement, automatic elevation, telemetry upload, or file-manager replacement features. +## Get started -## State and recovery +ZipXP needs Windows 11 and a local NTFS drive. There is no installer download yet, so for now build it from source with the [.NET 10 SDK](https://dotnet.microsoft.com/download): -Normal state: `%LOCALAPPDATA%\ZipXP\StorageManager\storage.sqlite3` plus SQLite WAL/SHM files. The main UI and tray share one process; SQLite is supplied by Windows' `winsqlite3.dll`. There are no external NuGet or UI packages. - -For an isolated instance, pass a Windows path: - -```bash -./storage-manager/run-wsl.sh --data-dir 'C:\Temp\ZipXP-isolated' +```powershell +git clone https://github.com/kiranscript/zipxp.git +cd zipxp +dotnet run --project src/ZipXP.App/ZipXP.App.csproj ``` -Press Ctrl+C in the terminal to stop a dev run: the launcher asks the app to quit cleanly (stopping the worker and removing the tray icon), and force-ends it after about 10 seconds if it doesn't. - -Only one worker runs for a user/data directory. A second launch activates the existing window. The policy database must not be placed inside a managed root. Startup registration is off unless explicitly enabled. Native compression persists independently of app state. +Then choose **Managed folders → Add folder…**, pick a test folder that holds copies of some documents, and read the estimate. To build a package you can install, see [Install and uninstall](docs/install.md). -After a crash, previously running jobs become retry records and actual state/identity is rechecked. A file already compressed by an interrupted operation is recorded as unchanged without inventing a savings measurement. Files changed while offline are found on startup. There is no rollback claim. +Storage insights shows which folders take the room and what was saved in each: -To back up the policy/history database, exit the tray worker normally and copy the state directory. Keep a backup before replacing a release with an older version; newer schema versions are rejected. Removing the database removes policies/history, not file contents or their native compression state. +

+ ZipXP storage insights by folder +

-## Build and verification - -```powershell -# From storage-manager/ on Windows: -.\scripts\check.ps1 -# Or select a nonstandard Windows SDK: -.\scripts\check.ps1 -Dotnet C:\Temp\zipxp-dotnet\dotnet.exe -``` +Compression savings depend entirely on what is in the folder. One known accounting issue (see [validation](docs/validation.md)) can overstate how much space is freed after restoring some files. Text, source code, documents and logs shrink well; photos, video and archives are already compressed and barely change. ZipXP measures the real result per file and skips files that don't benefit. -The check harness references the actual core library. It creates a unique disposable NTFS run directory in the user's temp folder and retains its files. It uses real compression, hashes, locks, hard links, directory defaults, replacements, and the persistent automatic worker; injected battery/CPU/free-space signals exercise waiting policies without filling a disk. A separate isolated database seeds the actual WPF window for native UI Automation navigation tests. The launch-check instance exits normally on its own and does not register startup. +## Documentation -Validation on the development Windows host is recorded in [VALIDATION.md](VALIDATION.md). Wider compatibility/performance testing, signing with a release certificate, sign-in lifecycle checks, and a private user pilot remain release acceptance work. This is an unsigned development build until published with a real signing certificate; it is not presented as a completed private beta. +| | | +|---|---| +| [Using ZipXP](docs/usage.md) | Add folders, turn on automatic compression, restore, stop managing | +| [How it works](docs/how-it-works.md) | What the app does and how savings are counted | +| [Safety, limits and recovery](docs/safety.md) | What ZipXP won't touch, filesystem limits, backups and crash recovery | +| [Install and uninstall](docs/install.md) | Build a package, install per user, remove cleanly | +| [Development](docs/development.md) | Source layout, WSL launcher, running the checks | +| [Validation record](docs/validation.md) | What has been tested, known issues, what is still missing | -## Publish and install +## Project layout -```powershell -.\scripts\publish.ps1 -# Optional real code-signing certificate already in CurrentUser\My: -.\scripts\publish.ps1 -SigningThumbprint YOUR_CERTIFICATE_THUMBPRINT -TimestampServer YOUR_TIMESTAMP_SERVER +```text +src/ZipXP.Core/ compression engine, queue, SQLite store +src/ZipXP.App/ WPF dashboard and tray app +tests/ real-filesystem checks +scripts/ dev launcher, check, publish, install +docs/ documentation +assets/ logo and screenshots ``` -Publishing produces a self-contained Windows x64 app and ZIP under `artifacts/`. A normal installed app does not need a separate .NET SDK/runtime. Without a signing certificate the package is explicitly labeled unsigned. The script does not create or substitute a signing identity. - -Run `.\scripts\package-check.ps1` after publishing to verify an isolated install, self-contained dashboard launch, graceful exit, and uninstall that preserves data. It does not create a Start menu shortcut or change login registration. Pass `-Package` for a different extracted package directory. - -Extract the ZIP and run its `install.ps1`. It installs for the current user under `%LOCALAPPDATA%\Programs\ZipXP Storage Manager`, creates a Start menu shortcut, and preserves policy/history data. Add `-StartAtLogin` and/or `-Launch` to explicitly enable those actions. For updates, exit the old tray worker before installing over it. The installer never force-kills a process. A custom `-Destination` and `-NoShortcut` support isolated installation checks. +## Contributing -Run the installed `uninstall.ps1` after exiting the tray worker. It verifies its installation record, removes the app's files, matching startup registration and shortcut, and leaves managed files and the local policy/history database intact. Reinstalling can reuse those retained policies. Test data is not deleted automatically. +Issues and pull requests are welcome. Run `scripts/check.ps1` on Windows before sending a change; see [Development](docs/development.md). -## Source layout - -```text -StorageManager.Core/ Models, native handles/identities, SQLite store, analysis, rules, worker -StorageManager.App/ WPF dashboard, policy editor, tray/single-instance/startup integration -StorageManager.Checks/ Actual-service policy, native, persistence, and automation checks -scripts/ Verification, self-contained publishing, install/uninstall -run-wsl.sh Windows SDK launcher from WSL -``` +## License -Native references: [FSCTL_SET_COMPRESSION](https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_set_compression), [FILE_ID_INFO](https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_id_info), [FILE_BASIC_INFO](https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_basic_info), [SQLite prepared statements](https://www.sqlite.org/c3ref/prepare.html), and [bound parameters](https://www.sqlite.org/c3ref/bind_blob.html). +[MIT](LICENSE) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..a41ad51 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security policy + +ZipXP changes files on your disk, so please report problems that could cause data loss or privilege issues privately. + +**To report a vulnerability or data-loss bug:** use GitHub's private vulnerability reporting for this repository (Security tab > Report a vulnerability). Please do not open a public issue for it. Include the ZipXP version or commit, your Windows version, and steps to reproduce. + +ZipXP is a pre-release project maintained on a best-effort basis. Only the latest version on `main` receives fixes. diff --git a/ZipXP.slnx b/ZipXP.slnx new file mode 100644 index 0000000..8964427 --- /dev/null +++ b/ZipXP.slnx @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/assets/brand/logo-wordmark.svg b/assets/brand/logo-wordmark.svg new file mode 100644 index 0000000..7eb7668 --- /dev/null +++ b/assets/brand/logo-wordmark.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + ZipXP + diff --git a/assets/brand/logo.svg b/assets/brand/logo.svg new file mode 100644 index 0000000..5fbdc08 --- /dev/null +++ b/assets/brand/logo.svg @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assets/brand/social-preview.png b/assets/brand/social-preview.png new file mode 100644 index 0000000..f567c0f Binary files /dev/null and b/assets/brand/social-preview.png differ diff --git a/assets/screenshots/managed-folders.png b/assets/screenshots/managed-folders.png new file mode 100644 index 0000000..9b04423 Binary files /dev/null and b/assets/screenshots/managed-folders.png differ diff --git a/assets/screenshots/overview.png b/assets/screenshots/overview.png new file mode 100644 index 0000000..7ef68cf Binary files /dev/null and b/assets/screenshots/overview.png differ diff --git a/assets/screenshots/storage-insights.png b/assets/screenshots/storage-insights.png new file mode 100644 index 0000000..df9bc3c Binary files /dev/null and b/assets/screenshots/storage-insights.png differ diff --git a/docs/development.md b/docs/development.md new file mode 100644 index 0000000..8f1d7e8 --- /dev/null +++ b/docs/development.md @@ -0,0 +1,70 @@ +# Development + +## Run from WSL + +From the repository root: + +```bash +./scripts/dev.sh +``` + +This launches the native Windows desktop app using Windows `dotnet.exe`. It looks on PATH, in `C:\Program Files\dotnet`, and in the local `C:\Temp\zipxp-dotnet` SDK used for development. Set `WINDOWS_DOTNET_EXE` to another executable's WSL path if needed. A Linux SDK cannot run WPF. + +From Windows PowerShell at the repository root: + +```powershell +dotnet run --project src/ZipXP.App/ZipXP.App.csproj +``` + +### Isolated and clean runs + +For an isolated instance, pass a Windows path: + +```bash +./scripts/dev.sh --data-dir 'C:\Temp\ZipXP-isolated' +``` + +Starting clean: the app keeps its folders, settings and history in `%LOCALAPPDATA%\ZipXP\StorageManager`, so a rebuild still shows old data. Launcher options (others are passed to the app): + +```bash +./scripts/dev.sh --fresh # empty throwaway data; your real data is untouched +./scripts/dev.sh --rebuild # delete bin/ and obj/ first, so nothing stale is reused +./scripts/dev.sh --reset # erase your real saved data (asks for confirmation), then start empty +./scripts/dev.sh --rebuild --fresh +``` + +Erasing data does not undo compression; files already compressed stay compressed. + +Press Ctrl+C in the terminal to stop a dev run: the launcher asks the app to quit cleanly (stopping the worker and removing the tray icon), and force-ends it after about 10 seconds if it doesn't. + +## Build and verification + +```powershell +# From the repository root on Windows: +.\scripts\check.ps1 +# Or select a nonstandard Windows SDK: +.\scripts\check.ps1 -Dotnet C:\Temp\zipxp-dotnet\dotnet.exe +``` + +The check harness references the actual core library. It creates a unique disposable NTFS run directory in the user's temp folder and retains its files. It uses real compression, hashes, locks, hard links, directory defaults, replacements, and the persistent automatic worker; injected battery/CPU/free-space signals exercise waiting policies without filling a disk. A separate isolated database seeds the actual WPF window for native UI Automation navigation tests. The launch-check instance exits normally on its own and does not register startup. + +Validation on the development Windows host is recorded in [validation.md](validation.md). Wider compatibility/performance testing, signing with a release certificate, sign-in lifecycle checks, and a private user pilot remain release acceptance work. This is an unsigned development build until published with a real signing certificate; it is not presented as a completed private beta. + +## Source layout + +```text +src/ZipXP.Core/ Models, native handles/identities, SQLite store, analysis, rules, worker +src/ZipXP.App/ WPF dashboard (Views/), controls, tray/single-instance/startup (Shell/), plain-language text (Text/) +tests/ZipXP.Checks/ Real-service policy, native, persistence and automation checks +tests/ZipXP.FolderTest/ Helper used by scripts/test-existing-folder.ps1 +scripts/ dev.sh (WSL launcher), check, publish, install, uninstall +docs/ Usage, how it works, safety, install, development, validation +``` + +The `.slnx` solution at the repository root opens all four projects. + +### Names that must not change + +The product is ZipXP. A few internal identifiers still say `StorageManager` on purpose, because renaming them would orphan existing users' data or startup entries: the data folder `%LOCALAPPDATA%\ZipXP\StorageManager`, the `ZipXP.StorageManager` executable/assembly, the sign-in registry value, the single-instance name, and the install folder. + +Native references: [FSCTL_SET_COMPRESSION](https://learn.microsoft.com/en-us/windows/win32/api/winioctl/ni-winioctl-fsctl_set_compression), [FILE_ID_INFO](https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_id_info), [FILE_BASIC_INFO](https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-file_basic_info), [SQLite prepared statements](https://www.sqlite.org/c3ref/prepare.html), and [bound parameters](https://www.sqlite.org/c3ref/bind_blob.html). diff --git a/docs/how-it-works.md b/docs/how-it-works.md new file mode 100644 index 0000000..659c7d4 --- /dev/null +++ b/docs/how-it-works.md @@ -0,0 +1,25 @@ +# How ZipXP works + +## What is implemented + +- Recursive managed roots with overlap rejection, policy exclusions, no reparse-point traversal, partial scans, and independent read-only analysis. +- A persistent single sequential queue, stable volume/file identities, fresh metadata validation, native handle-based compression, retry/backoff, cancellation between files, and crash reconciliation. +- Automatic existing/new/copied/replaced-file processing, watcher error reconciliation, quiet periods, cooldowns, and poor-result caching. +- Folder schedules (local hours, including overnight), battery control, free-space reserves, and pausing new file operations above 85% sampled total system CPU usage. These are gates between operations, not hard resource caps. +- One below-normal-priority per-user process with a tray, a single-instance activation event, optional sign-in registration, and graceful exit. No service or elevation is needed. +- Overview cards, live volume usage, managed-folder policies/status, largest-file/folder drill-down, scan allocation history, searchable activity, retry, and copyable diagnostics. +- SQLite schema migrations, local observations/jobs/settings, a daily signed allocation ledger that survives detailed-history pruning, and bounded retention. +- A WSL launcher, Windows service/UI checks, self-contained publishing, optional certificate signing, and per-user install/uninstall scripts. + +## Storage accounting + +All file measurements cover the primary data stream. Directory metadata and named streams are excluded. Unknown sizes display a dash. Scans deduplicate observed hard links within a root; the overview deduplicates known file identities across managed roots. Excluded subtrees are outside the policy scope. + +The UI keeps four different quantities separate: + +1. **Volume usage/free space:** current drive statistics, including activity from all applications. +2. **Managed allocation:** known primary-stream allocations from each root's latest scan, with scan timestamps and unknown-entry coverage. This is not an atomic volume snapshot. +3. **Estimated opportunity:** three 32 KiB Deflate samples per eligible file, scaled as a heuristic. NTFS uses a different compression algorithm; the estimate is not a promise. Sampling does not mutate files. +4. **Net measured reduction:** signed `before allocation - after allocation` for successful operations with stable identity, length, and last-write time. Zero is valid; decompression growth is negative. Already-compressed/interrupted/unmeasured jobs claim no new bytes. The ledger records each completed job once and survives restart. Period filtering uses UTC days. It is a historical operation total, not a claim of current free-space recovery or savings remaining after deletion. + +The history chart plots scan allocations for the selected root and period, at actual scan times. Amber bars indicate incomplete/unknown coverage; timestamps without a scan have no bar. It includes up to 32 recent scans in the period. Detailed jobs show at most 1,000 matching recent rows; up to 10,000 terminal records and 2,000 scan summaries are retained. Ledger totals are separate from that retention. diff --git a/docs/install.md b/docs/install.md new file mode 100644 index 0000000..68ec8a8 --- /dev/null +++ b/docs/install.md @@ -0,0 +1,17 @@ +# Install and uninstall + +## Publish a package + +```powershell +.\scripts\publish.ps1 +# Optional real code-signing certificate already in CurrentUser\My: +.\scripts\publish.ps1 -SigningThumbprint YOUR_CERTIFICATE_THUMBPRINT -TimestampServer YOUR_TIMESTAMP_SERVER +``` + +Publishing produces a self-contained Windows x64 app and ZIP under `artifacts/`. A normal installed app does not need a separate .NET SDK/runtime. Without a signing certificate the package is explicitly labeled unsigned. The script does not create or substitute a signing identity. + +Run `.\scripts\package-check.ps1` after publishing to verify an isolated install, self-contained dashboard launch, graceful exit, and uninstall that preserves data. It does not create a Start menu shortcut or change login registration. Pass `-Package` for a different extracted package directory. + +Extract the ZIP and run its `install.ps1`. It installs for the current user under `%LOCALAPPDATA%\Programs\ZipXP Storage Manager`, creates a Start menu shortcut, and preserves policy/history data. Add `-StartAtLogin` and/or `-Launch` to explicitly enable those actions. For updates, exit the old tray worker before installing over it. The installer never force-kills a process. A custom `-Destination` and `-NoShortcut` support isolated installation checks. + +Run the installed `uninstall.ps1` after exiting the tray worker. It verifies its installation record, removes the app's files, matching startup registration and shortcut, and leaves managed files and the local policy/history database intact. Reinstalling can reuse those retained policies. Test data is not deleted automatically. diff --git a/docs/safety.md b/docs/safety.md new file mode 100644 index 0000000..dbf1996 --- /dev/null +++ b/docs/safety.md @@ -0,0 +1,29 @@ +# Safety, limits and recovery + +ZipXP asks Windows to compress your files in place. It does not delete, move or rename them, and files keep their names and paths. This is still a pre-release: use disposable copies until broader acceptance testing is complete. + +## Filesystem and resource boundaries + +- Local fixed NTFS with file-compression support; no drive-root management, Windows/Program Files locations, UNC/device paths, WSL filesystem roots, or reparse-point ancestors/children. +- Hidden/system, encrypted, sparse, offline/recall, read-only, multiple-hard-link files, and unsupported entries are excluded from mutation. Inspection/access errors are visible rather than silently counted as zero. +- Initial tested manual/automatic compression sizes are 64 KiB–256 MiB. Decompression can include smaller compressed files, up to the policy's tested maximum. Policies cannot enlarge that maximum yet. +- Reserve is at least 256 MiB for compression, and full logical size plus reserve for decompression. The queue waits for space rather than filling a disk in a test. The OS may still reject a previously checked operation. +- Mutation opens one original file handle with no write/delete sharing, checks the resolved path and stable identity, validates content metadata, invokes `FSCTL_SET_COMPRESSION`, and reads back actual state/allocation from that same handle. A replacement or changed file is skipped for a rescan. Existing writers may cause a retryable sharing violation. +- Normal cancellation does not kill in-flight native I/O. Only one file mutation runs at a time, with a 500 ms worker interval. Scanning is sequential, bounded to 100,000 observations per root; automatic event-triggered rescans are spaced by at least 15 seconds. The queue holds at most 2,000 active jobs and refills through reconciliation. +- Very large roots should be split into smaller nonoverlapping managed scopes. Scans reaching the observation bound explicitly report incomplete coverage; this build does not provide resumable pagination past that bound. +- Native operations, file identity checks, and sharing restrictions improve race handling but are not a production data-integrity guarantee against every concurrent filesystem change. Use disposable copies until broader acceptance is complete. +- No recursive deletion/cleanup, deduplication mutation, cloud/network support, WOF, archive replacement, automatic elevation, telemetry upload, or file-manager replacement features. + +## State and recovery + +Normal state: `%LOCALAPPDATA%\ZipXP\StorageManager\storage.sqlite3` plus SQLite WAL/SHM files. The main UI and tray share one process; SQLite is supplied by Windows' `winsqlite3.dll`. There are no external NuGet or UI packages. + +Only one worker runs for a user/data directory. A second launch activates the existing window. The policy database must not be placed inside a managed root. Startup registration is off unless explicitly enabled. Native compression persists independently of app state. + +After a crash, previously running jobs become retry records and actual state/identity is rechecked. A file already compressed by an interrupted operation is recorded as unchanged without inventing a savings measurement. Files changed while offline are found on startup. There is no rollback claim. + +To back up the policy/history database, exit the tray worker normally and copy the state directory. Keep a backup before replacing a release with an older version; newer schema versions are rejected. Removing the database removes policies/history, not file contents or their native compression state. + +## Known issues + +After decompression, allocation can be measured before the file handle is closed, which overstates growth for some file sizes and can show a small negative savings total. Files themselves are unaffected. Tracked in [#2](https://github.com/kiranscript/zipxp/issues/2); see [validation](validation.md). diff --git a/docs/usage.md b/docs/usage.md new file mode 100644 index 0000000..f718a59 --- /dev/null +++ b/docs/usage.md @@ -0,0 +1,20 @@ +# Using ZipXP + +## Getting started + +1. Select **Managed folders → Add folder…**. Choose a local fixed NTFS folder, such as `C:\zipxp-test`. Adding a folder starts read-only analysis. A WSL/UNC folder is not supported. +2. Inspect the overview and storage insights. Folder rows show their policy, known logical/allocation totals, candidate bytes, status, scan time, and native directory-default count. Double-click a folder in Insights to drill down, or choose **Largest files**. +3. Select **Folder settings** and turn on automatic compression. Subfolder inclusion and battery behavior are on the first screen; file exclusions, size/benefit thresholds, quiet period, cooldown, schedule, and free-space reserve are under **Advanced options**. +4. Eligible existing files are queued. New, copied-in, replaced, and changed files are discovered through notifications and periodic scans. The recommended quiet period is 60 seconds; reconciliation runs every two minutes. Busy files retry with backoff. Poor-benefit files stay excluded until their content fingerprint changes or a failed job is explicitly retried. +5. Close the window to keep the tray worker running. Reopen it from the tray. **Start when I sign in** explicitly registers this user's current launch command. **Pause all** / **Pause folder** stops new operations after the current one. **Quit ZipXP** finishes the file in progress, then ends the worker and leaves pending work persisted. +6. Use Activity to search/filter outcomes, copy diagnostics, and retry selected failures. Retry does not re-enable disabled automatic policies. + +Adding a folder for analysis does not compress it. **Compress now** is an explicit one-off job; it does not turn on future automation. Each recursive action shows a scope preview first. Ordinary automatic files have no per-file confirmation dialog. + +### Decompression and stopping management + +- **Restore original size…** (Overview for all folders, Managed folders toolbar per folder, or Storage insights for selected files) uncompresses files so they take their full space again; no files are deleted. It first disables automatic compression for that managed root and cancels pending compression. Re-enabling automation while decompression is pending is rejected. +- Decompression does not clear existing NTFS directory defaults. The preview reports those defaults, incomplete coverage, omitted entries, and the largest sequential operation's required headroom. +- **Turn off Windows' own folder compression** (More menu) is a separate recursive directory-only job within the current policy scope. Existing files stay compressed. Excluded/unreadable/unsupported directories may retain defaults; inspect the next scan. +- **Stop managing this folder** (More menu) removes the root, observations, and future jobs. Existing files and native defaults remain unchanged. Historical job measurements are retained. +- Resuming/pausing the selective worker does not change any native directory inheritance settings. Such defaults can compress future files even while the app is closed and can bypass the selective worker's exclusions and size limits. diff --git a/storage-manager/VALIDATION.md b/docs/validation.md similarity index 64% rename from storage-manager/VALIDATION.md rename to docs/validation.md index 19544bf..4097798 100644 --- a/storage-manager/VALIDATION.md +++ b/docs/validation.md @@ -12,20 +12,20 @@ Development host: Windows display version 26H2, build 26300.9711; .NET SDK 10.0. - Isolated per-user installation, installed self-contained dashboard launch, graceful exit, and uninstall preserving the policy/history database: passed. No test created a shortcut or startup registration. - Static shell syntax, source whitespace, and local documentation links: passed. -The final core fixture run was retained at `C:\Users\kiran\AppData\Local\Temp\ZipXP-Manager-checks-082943c57d3341af9af25c26fa92066d`. The successful package lifecycle state was retained at `C:\Users\kiran\AppData\Local\Temp\ZipXP-package-check-6aee2ef8f445402da8ece8c04a655598`. The development package is `C:\Temp\ZipXP-StorageManager-package.zip`. These paths are local test evidence, not required application paths. +Fixture and package-lifecycle folders from these runs were retained locally as test evidence; they are not required application paths. Runtime testing found and fixed a launch-check assumption about console-host `WaitForInputIdle`, missing-startup-entry handling in PowerShell uninstall, and an operation-cache edge case that could block explicit decompression. The final executed checks have no unresolved failures. ## Additional real-folder run: accounting defect found -A subsequent manual 35-file test (2026-11-09; its evidence files have since been removed from the repository) exercised the actual app on `C:\Users\kiran\zipxp-test`, including the default quiet period, closed-window background work, restart catch-up, and GUI decompression. All original hashes and recorded file metadata were preserved and restored. +A subsequent manual 35-file test (2026-11-09; its evidence files have since been removed from the repository) exercised the actual app on a local test folder, including the default quiet period, closed-window background work, restart catch-up, and GUI decompression. All original hashes and recorded file metadata were preserved and restored. -That run found an **open allocation-accounting defect** not covered by the earlier aligned-size fixtures: reading post-decompression allocation before closing the mutation handle overstates growth for some non-aligned lengths. Three files produced an erroneous **−84 KiB** round-trip ledger total although final allocation exactly matched the baseline. A separate 65,537-byte reproduction confirmed 131,072 allocated bytes while the mutation handle remained open versus 69,632 after close. Application code remains unchanged by this reporting task. See the report for affected files, raw evidence, and the recommended measurement correction. +That run found an **open allocation-accounting defect (known issue)** not covered by the earlier aligned-size fixtures: reading post-decompression allocation before closing the mutation handle overstates growth for some non-aligned lengths. Three files produced an erroneous **−84 KiB** round-trip ledger total although final allocation exactly matched the baseline. A separate 65,537-byte reproduction confirmed 131,072 allocated bytes while the mutation handle remained open versus 69,632 after close. The recommended correction is to read the allocation after the mutation handle is closed. ## Release acceptance still required - Broad Windows/NTFS cluster-size, hardware, permissions, antivirus, and backup/restore compatibility matrix. -- Repeated workload CPU/I/O/open/save latency measurements and the plan's pilot savings/performance targets. +- Repeated workload CPU/I/O/open/save latency measurements and pilot savings/performance targets. - Actual Windows sign-out/restart/sign-in validation of optional startup registration and window-to-tray behavior during long operations. - A release certificate, trusted timestamping, and validation of a signed production package. No certificate is supplied in this workspace. - Real user pilot, accessibility review, and installation/update recovery on additional machines. diff --git a/storage-manager/scripts/check.ps1 b/scripts/check.ps1 similarity index 84% rename from storage-manager/scripts/check.ps1 rename to scripts/check.ps1 index e8be997..4977fe7 100644 --- a/storage-manager/scripts/check.ps1 +++ b/scripts/check.ps1 @@ -1,16 +1,16 @@ [CmdletBinding()] param([string]$Dotnet = 'dotnet') $ErrorActionPreference = 'Stop' -$manager = Split-Path -Parent $PSScriptRoot -& $Dotnet build (Join-Path $manager 'StorageManager.App/StorageManager.App.csproj') --nologo +$root = Split-Path -Parent $PSScriptRoot +& $Dotnet build (Join-Path $root 'src/ZipXP.App/ZipXP.App.csproj') --nologo if ($LASTEXITCODE -ne 0) { throw 'WPF build failed.' } -& $Dotnet run --project (Join-Path $manager 'StorageManager.Checks/StorageManager.Checks.csproj') +& $Dotnet run --project (Join-Path $root 'tests/ZipXP.Checks/ZipXP.Checks.csproj') if ($LASTEXITCODE -ne 0) { throw 'Service/integration checks failed.' } $state = Join-Path $env:TEMP ('ZipXP-window-check-' + [Guid]::NewGuid().ToString('N')) -& $Dotnet run --project (Join-Path $manager 'StorageManager.Checks/StorageManager.Checks.csproj') -- --seed-ui $state +& $Dotnet run --project (Join-Path $root 'tests/ZipXP.Checks/ZipXP.Checks.csproj') -- --seed-ui $state if ($LASTEXITCODE -ne 0) { throw 'UI fixture setup failed.' } -$dll = Join-Path $manager 'StorageManager.App/bin/Debug/net10.0-windows/ZipXP.StorageManager.dll' +$dll = Join-Path $root 'src/ZipXP.App/bin/Debug/net10.0-windows/ZipXP.StorageManager.dll' $start = [Diagnostics.ProcessStartInfo]::new() $start.FileName = (Get-Command $Dotnet).Source $start.UseShellExecute = $false @@ -25,7 +25,7 @@ try { if ($app.HasExited -or $app.MainWindowHandle -ne 0) { break } Start-Sleep -Milliseconds 100 } while ([DateTime]::UtcNow -lt $deadline) - if ($app.HasExited -or $app.MainWindowHandle -eq 0 -or $app.MainWindowTitle -notlike 'ZipXP*Storage Manager') { throw 'Storage Manager window was not found.' } + if ($app.HasExited -or $app.MainWindowHandle -eq 0 -or $app.MainWindowTitle -notlike 'ZipXP*') { throw 'ZipXP window was not found.' } Write-Host "PASS: actual WPF dashboard launched: $($app.MainWindowTitle)" Add-Type -AssemblyName UIAutomationClient Add-Type -AssemblyName UIAutomationTypes diff --git a/scripts/dev.sh b/scripts/dev.sh new file mode 100755 index 0000000..f193ce0 --- /dev/null +++ b/scripts/dev.sh @@ -0,0 +1,88 @@ +#!/usr/bin/env bash +set -euo pipefail +command -v wslpath >/dev/null 2>&1 || { echo 'Use this launcher from WSL with Windows executable interop enabled.' >&2; exit 1; } +repo_root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)" +windows_dotnet="${WINDOWS_DOTNET_EXE:-$(command -v dotnet.exe || true)}" +if [[ -z "$windows_dotnet" ]]; then + for candidate in '/mnt/c/Program Files/dotnet/dotnet.exe' '/mnt/c/Temp/zipxp-dotnet/dotnet.exe'; do + if [[ -f "$candidate" ]]; then windows_dotnet="$candidate"; break; fi + done +fi +if [[ ! -f "$windows_dotnet" ]]; then + echo 'Install the .NET 10 SDK on Windows or set WINDOWS_DOTNET_EXE to its WSL path.' >&2 + exit 1 +fi +# Launcher options (everything else is passed on to the app): +# --rebuild delete bin/ and obj/ first, so nothing stale is reused +# --fresh start with empty data in a throwaway folder; your real data is untouched +# --reset erase your real saved data (asks first), then start empty + +usage() { sed -n '/^# Launcher options/,/^$/p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; } +rebuild=0 fresh=0 reset=0 app_args=() +for arg in "$@"; do + case "$arg" in + --rebuild) rebuild=1 ;; + --fresh) fresh=1 ;; + --reset) reset=1 ;; + -h|--help) usage; exit 0 ;; + *) app_args+=("$arg") ;; + esac +done +if (( fresh && reset )); then echo 'Use either --fresh or --reset, not both.' >&2; exit 2; fi + +win_path() { powershell.exe -NoProfile -Command "$1" /dev/null || true +fi + +if (( fresh )); then + data_dir="$(win_path '[IO.Path]::Combine([IO.Path]::GetTempPath(), "ZipXP-dev-fresh")')" + rm -rf "$(wslpath -u "$data_dir")" + echo "Fresh start: using empty data in $data_dir (your real data is untouched)." + app_args+=(--data-dir "$data_dir") +elif (( reset )); then + data_dir="$(win_path '[IO.Path]::Combine($env:LOCALAPPDATA, "ZipXP", "StorageManager")')" + echo "This permanently erases ZipXP's saved folders, settings and history in:" + echo " $data_dir" + echo "Files already compressed stay compressed (use Restore original size first if you want them back)." + read -r -p 'Type "reset" to continue: ' answer + [[ "$answer" == reset ]] || { echo 'Cancelled.'; exit 1; } + if ! rm -rf "$(wslpath -u "$data_dir")"; then echo 'Could not erase it. Quit ZipXP first (tray icon > Quit ZipXP).' >&2; exit 1; fi + echo 'Saved data erased.' +fi + +"$windows_dotnet" build "$(wslpath -w "$repo_root/src/ZipXP.App/ZipXP.App.csproj")" --nologo + +# Run the app as a child so Ctrl+C (or a terminal close / kill) can shut it down. +# The app is a Windows GUI process: it has no console of its own, so a plain Ctrl+C can +# leave it running in the tray and locking bin/ for the next build. +run_id="zipxp-dev-$$-$(date +%s)" +quit_file="$(mktemp "${TMPDIR:-/tmp}/zipxp-quit.XXXXXX")" +rm -f "$quit_file" +"$windows_dotnet" "$(wslpath -w "$repo_root/src/ZipXP.App/bin/Debug/net10.0-windows/ZipXP.StorageManager.dll")" \ + --dev-run-id "$run_id" --quit-file "$(wslpath -w "$quit_file")" "${app_args[@]}" & +app_pid=$! + +stop_app() { + trap - INT TERM HUP + echo; echo 'Stopping ZipXP...' + : > "$quit_file" # ask the app to quit cleanly + for _ in $(seq 1 100); do # up to ~10 s + kill -0 "$app_pid" 2>/dev/null || break + sleep 0.1 + done + if kill -0 "$app_pid" 2>/dev/null; then # still there: force it + echo 'ZipXP did not stop in time, ending it.' + powershell.exe -NoProfile -Command "Get-CimInstance Win32_Process | Where-Object { \$_.CommandLine -like '*$run_id*' } | ForEach-Object { Stop-Process -Id \$_.ProcessId -Force }" >/dev/null 2>&1 || true + kill "$app_pid" 2>/dev/null || true + fi + rm -f "$quit_file" + exit 130 +} +trap stop_app INT TERM HUP + +wait "$app_pid" && status=0 || status=$? +rm -f "$quit_file" +exit "$status" diff --git a/storage-manager/scripts/install.ps1 b/scripts/install.ps1 similarity index 94% rename from storage-manager/scripts/install.ps1 rename to scripts/install.ps1 index 0b75814..97090b1 100644 --- a/storage-manager/scripts/install.ps1 +++ b/scripts/install.ps1 @@ -10,7 +10,7 @@ $ErrorActionPreference = 'Stop' if (-not (Test-Path -LiteralPath (Join-Path $Source 'ZipXP.StorageManager.exe'))) { throw 'Extract the published package and run its install.ps1, or supply -Source with the published app directory.' } $Destination = [IO.Path]::GetFullPath($Destination) if (Get-Process -Name 'ZipXP.StorageManager' -ErrorAction SilentlyContinue | Where-Object { $_.Path -and $_.Path.StartsWith($Destination + '\', [StringComparison]::OrdinalIgnoreCase) }) { - throw 'Exit Storage Manager using its tray menu before installing or updating. No process will be force-killed.' + throw 'Quit ZipXP from its tray menu before installing or updating. No process will be force-killed.' } New-Item -ItemType Directory -Force -Path $Destination | Out-Null Copy-Item -Path (Join-Path $Source '*') -Destination $Destination -Recurse -Force diff --git a/storage-manager/scripts/package-check.ps1 b/scripts/package-check.ps1 similarity index 95% rename from storage-manager/scripts/package-check.ps1 rename to scripts/package-check.ps1 index d18c025..e6aee2c 100644 --- a/storage-manager/scripts/package-check.ps1 +++ b/scripts/package-check.ps1 @@ -16,7 +16,7 @@ try { if ($app.HasExited -or $app.MainWindowHandle -ne 0) { break } Start-Sleep -Milliseconds 100 } while ([DateTime]::UtcNow -lt $deadline) - if ($app.HasExited -or $app.MainWindowHandle -eq 0 -or $app.MainWindowTitle -notlike 'ZipXP*Storage Manager') { throw 'Published app window not found.' } + if ($app.HasExited -or $app.MainWindowHandle -eq 0 -or $app.MainWindowTitle -notlike 'ZipXP*') { throw 'Published app window not found.' } Write-Host 'PASS: installed self-contained executable opens the dashboard.' if (-not $app.WaitForExit(25000)) { throw 'Installed app did not exit gracefully.' } if ($app.ExitCode -ne 0) { throw "Installed app exited with $($app.ExitCode)." } diff --git a/storage-manager/scripts/publish.ps1 b/scripts/publish.ps1 similarity index 66% rename from storage-manager/scripts/publish.ps1 rename to scripts/publish.ps1 index 6edcfce..306fe1d 100644 --- a/storage-manager/scripts/publish.ps1 +++ b/scripts/publish.ps1 @@ -6,16 +6,18 @@ param( [string]$TimestampServer ) $ErrorActionPreference = 'Stop' -$manager = Split-Path -Parent $PSScriptRoot -if (-not $Output) { $Output = Join-Path $manager 'artifacts/win-x64' } +$root = Split-Path -Parent $PSScriptRoot +if (-not $Output) { $Output = Join-Path $root 'artifacts/win-x64' } $Output = [IO.Path]::GetFullPath($Output) $appFolder = Join-Path $Output 'app' -& $Dotnet publish (Join-Path $manager 'StorageManager.App/StorageManager.App.csproj') -c Release -r win-x64 --self-contained true -o $appFolder --nologo +$version = (& $Dotnet msbuild (Join-Path $root 'src/ZipXP.App/ZipXP.App.csproj') -getProperty:Version --nologo | Out-String).Trim() +if (-not $version) { throw 'Could not read the version from Directory.Build.props.' } +& $Dotnet publish (Join-Path $root 'src/ZipXP.App/ZipXP.App.csproj') -c Release -r win-x64 --self-contained true -o $appFolder --nologo if ($LASTEXITCODE -ne 0) { throw 'Publish failed.' } $signature = 'Unsigned development build' if ($SigningThumbprint) { $certificate = Get-Item -LiteralPath ('Cert:\CurrentUser\My\' + $SigningThumbprint) - foreach ($file in @('ZipXP.StorageManager.exe', 'ZipXP.StorageManager.dll', 'StorageManager.Core.dll')) { + foreach ($file in @('ZipXP.StorageManager.exe', 'ZipXP.StorageManager.dll', 'ZipXP.Core.dll')) { $parameters = @{FilePath=(Join-Path $appFolder $file); Certificate=$certificate; HashAlgorithm='SHA256'} if ($TimestampServer) { $parameters.TimestampServer = $TimestampServer } $signed = Set-AuthenticodeSignature @parameters @@ -24,8 +26,9 @@ if ($SigningThumbprint) { $signature = "Signed with $SigningThumbprint" } Copy-Item -LiteralPath (Join-Path $PSScriptRoot 'install.ps1'),(Join-Path $PSScriptRoot 'uninstall.ps1') -Destination $Output -Copy-Item -LiteralPath (Join-Path $manager 'README.md'),(Join-Path $manager 'VALIDATION.md') -Destination $Output -Set-Content -LiteralPath (Join-Path $Output 'BUILD.txt') -Value "ZipXP Storage Manager 0.2.0`n$signature`nBuilt: $([DateTime]::UtcNow.ToString('O'))" -Encoding UTF8 +Copy-Item -LiteralPath (Join-Path $root 'README.md'),(Join-Path $root 'LICENSE'),(Join-Path $root 'CHANGELOG.md') -Destination $Output +Copy-Item -LiteralPath (Join-Path $root 'docs') -Destination $Output -Recurse -Force +Set-Content -LiteralPath (Join-Path $Output 'BUILD.txt') -Value "ZipXP $version`n$signature`nBuilt: $([DateTime]::UtcNow.ToString('O'))" -Encoding UTF8 Get-ChildItem -LiteralPath $appFolder -File -Recurse | ForEach-Object { [PSCustomObject]@{ Path=$_.FullName.Substring($Output.TrimEnd('\').Length + 1); Hash=(Get-FileHash -LiteralPath $_.FullName -Algorithm SHA256).Hash } } | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $Output 'SHA256.json') -Encoding UTF8 diff --git a/storage-manager/scripts/test-existing-folder.ps1 b/scripts/test-existing-folder.ps1 similarity index 98% rename from storage-manager/scripts/test-existing-folder.ps1 rename to scripts/test-existing-folder.ps1 index 02c1c45..959aa36 100644 --- a/storage-manager/scripts/test-existing-folder.ps1 +++ b/scripts/test-existing-folder.ps1 @@ -6,9 +6,9 @@ param( [switch]$SkipBackgroundChecks ) $ErrorActionPreference = 'Stop' -$manager = Split-Path -Parent $PSScriptRoot -$helper = Join-Path $PSScriptRoot 'folder-test/bin/Debug/net10.0-windows/FolderTest.dll' -$dll = Join-Path $manager 'StorageManager.App/bin/Debug/net10.0-windows/ZipXP.StorageManager.dll' +$root = Split-Path -Parent $PSScriptRoot +$helper = Join-Path $root 'tests/ZipXP.FolderTest/bin/Debug/net10.0-windows/ZipXP.FolderTest.dll' +$dll = Join-Path $root 'src/ZipXP.App/bin/Debug/net10.0-windows/ZipXP.StorageManager.dll' $data = Join-Path $Evidence 'isolated-state' $before = Join-Path $Evidence 'before.json' $results = [Collections.Generic.List[object]]::new() diff --git a/storage-manager/scripts/uninstall.ps1 b/scripts/uninstall.ps1 similarity index 94% rename from storage-manager/scripts/uninstall.ps1 rename to scripts/uninstall.ps1 index 26bdd9d..5523673 100644 --- a/storage-manager/scripts/uninstall.ps1 +++ b/scripts/uninstall.ps1 @@ -7,7 +7,7 @@ if (-not (Test-Path -LiteralPath $marker)) { throw 'This directory has no ZipXP $installation = Get-Content -Raw -LiteralPath $marker | ConvertFrom-Json if ($installation.product -ne 'ZipXP.StorageManager' -or -not $Destination.Equals($installation.installPath, [StringComparison]::OrdinalIgnoreCase) -or $Destination -eq [IO.Path]::GetPathRoot($Destination)) { throw 'Installation record does not match the directory.' } if (Get-Process -Name 'ZipXP.StorageManager' -ErrorAction SilentlyContinue | Where-Object { $_.Path -and $_.Path.StartsWith($Destination + '\', [StringComparison]::OrdinalIgnoreCase) }) { - throw 'Exit Storage Manager through its tray menu first; the current operation must be allowed to finish.' + throw 'Quit ZipXP from its tray menu first; the current operation must be allowed to finish.' } $run = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Run' $registration = Get-ItemProperty -Path $run -ErrorAction SilentlyContinue diff --git a/storage-manager/StorageManager.App/App.xaml b/src/ZipXP.App/App.xaml similarity index 99% rename from storage-manager/StorageManager.App/App.xaml rename to src/ZipXP.App/App.xaml index 7671ed0..23b95ea 100644 --- a/storage-manager/StorageManager.App/App.xaml +++ b/src/ZipXP.App/App.xaml @@ -1,7 +1,7 @@ - diff --git a/storage-manager/StorageManager.App/App.xaml.cs b/src/ZipXP.App/App.xaml.cs similarity index 95% rename from storage-manager/StorageManager.App/App.xaml.cs rename to src/ZipXP.App/App.xaml.cs index 8e188e9..90c2c7f 100644 --- a/storage-manager/StorageManager.App/App.xaml.cs +++ b/src/ZipXP.App/App.xaml.cs @@ -5,11 +5,11 @@ using System.Text; using System.Windows; using System.Windows.Threading; -using StorageManager.Core.Persistence; -using StorageManager.Core.Services; +using ZipXP.Core.Persistence; +using ZipXP.Core.Services; using Forms = System.Windows.Forms; -namespace StorageManager.App; +namespace ZipXP.App; public partial class App : Application { @@ -44,7 +44,7 @@ protected override void OnStartup(StartupEventArgs e) CreateTray(); Engine.Start(); if (!e.Args.Contains("--tray")) ShowMain(); - // Dev launcher (run-wsl.sh) creates this file on Ctrl+C to ask for a clean shutdown. + // Dev launcher (scripts/dev.sh) creates this file on Ctrl+C to ask for a clean shutdown. var quitIndex = Array.IndexOf(e.Args, "--quit-file"); if (quitIndex >= 0 && quitIndex + 1 < e.Args.Length) { @@ -89,7 +89,7 @@ private void CreateTray() })); menu.Opening += (_, _) => pause.Text = Engine.Paused ? "Resume" : "Pause"; menu.Items.Add("Quit ZipXP", null, (_, _) => Dispatcher.BeginInvoke(async () => await ExitAsync())); - tray = new Forms.NotifyIcon { Icon = LoadIcon(), Text = "ZipXP Storage Manager", ContextMenuStrip = menu, Visible = true }; + tray = new Forms.NotifyIcon { Icon = LoadIcon(), Text = "ZipXP", ContextMenuStrip = menu, Visible = true }; tray.DoubleClick += (_, _) => Dispatcher.BeginInvoke(ShowMain); } diff --git a/src/ZipXP.App/Assets/zipxp.ico b/src/ZipXP.App/Assets/zipxp.ico new file mode 100644 index 0000000..4fdf1ba Binary files /dev/null and b/src/ZipXP.App/Assets/zipxp.ico differ diff --git a/storage-manager/StorageManager.App/GlyphButton.cs b/src/ZipXP.App/Controls/GlyphButton.cs similarity index 96% rename from storage-manager/StorageManager.App/GlyphButton.cs rename to src/ZipXP.App/Controls/GlyphButton.cs index 98f417e..4077673 100644 --- a/storage-manager/StorageManager.App/GlyphButton.cs +++ b/src/ZipXP.App/Controls/GlyphButton.cs @@ -1,7 +1,7 @@ using System.Windows; using System.Windows.Controls; -namespace StorageManager.App; +namespace ZipXP.App; /// A button with an icon-font glyph before its text label, and an optional "current page" state. public class GlyphButton : Button diff --git a/storage-manager/StorageManager.App/GlobalUsings.cs b/src/ZipXP.App/GlobalUsings.cs similarity index 100% rename from storage-manager/StorageManager.App/GlobalUsings.cs rename to src/ZipXP.App/GlobalUsings.cs diff --git a/storage-manager/StorageManager.App/StartupRegistration.cs b/src/ZipXP.App/Shell/StartupRegistration.cs similarity index 96% rename from storage-manager/StorageManager.App/StartupRegistration.cs rename to src/ZipXP.App/Shell/StartupRegistration.cs index 6ff9923..0e697fe 100644 --- a/storage-manager/StorageManager.App/StartupRegistration.cs +++ b/src/ZipXP.App/Shell/StartupRegistration.cs @@ -1,7 +1,7 @@ using System.Reflection; using Microsoft.Win32; -namespace StorageManager.App; +namespace ZipXP.App; internal static class StartupRegistration { diff --git a/storage-manager/StorageManager.App/Plain.cs b/src/ZipXP.App/Text/Plain.cs similarity index 99% rename from storage-manager/StorageManager.App/Plain.cs rename to src/ZipXP.App/Text/Plain.cs index b38da8a..e66dc3d 100644 --- a/storage-manager/StorageManager.App/Plain.cs +++ b/src/ZipXP.App/Text/Plain.cs @@ -1,7 +1,7 @@ using System.Text.RegularExpressions; -using StorageManager.Core; +using ZipXP.Core; -namespace StorageManager.App; +namespace ZipXP.App; /// /// Turns the engine's precise, technical wording into everyday language for the window. diff --git a/storage-manager/StorageManager.App/MainWindow.xaml b/src/ZipXP.App/Views/MainWindow.xaml similarity index 99% rename from storage-manager/StorageManager.App/MainWindow.xaml rename to src/ZipXP.App/Views/MainWindow.xaml index 8d37f0e..811e3da 100644 --- a/storage-manager/StorageManager.App/MainWindow.xaml +++ b/src/ZipXP.App/Views/MainWindow.xaml @@ -1,8 +1,8 @@ - @@ -17,7 +17,7 @@ - + diff --git a/storage-manager/StorageManager.App/MainWindow.xaml.cs b/src/ZipXP.App/Views/MainWindow.xaml.cs similarity index 99% rename from storage-manager/StorageManager.App/MainWindow.xaml.cs rename to src/ZipXP.App/Views/MainWindow.xaml.cs index 84abbd7..cce61aa 100644 --- a/storage-manager/StorageManager.App/MainWindow.xaml.cs +++ b/src/ZipXP.App/Views/MainWindow.xaml.cs @@ -6,10 +6,10 @@ using System.Windows.Shapes; using System.Windows.Threading; using Microsoft.Win32; -using StorageManager.Core; -using StorageManager.Core.Services; +using ZipXP.Core; +using ZipXP.Core.Services; -namespace StorageManager.App; +namespace ZipXP.App; public partial class MainWindow : Window { diff --git a/storage-manager/StorageManager.App/PolicyWindow.xaml b/src/ZipXP.App/Views/PolicyWindow.xaml similarity index 99% rename from storage-manager/StorageManager.App/PolicyWindow.xaml rename to src/ZipXP.App/Views/PolicyWindow.xaml index 5dca98c..cd47a87 100644 --- a/storage-manager/StorageManager.App/PolicyWindow.xaml +++ b/src/ZipXP.App/Views/PolicyWindow.xaml @@ -1,7 +1,7 @@ -