Directory Junctions Move 10GB of WorkBuddy Data Off a Full C Drive With History Intact
Workbuddy takes too much C drive space, so I wrote a migration tool to move 10G of data
Follow my public account: 【编程朝花夕拾】 to get first-issued content.
01 Introduction
After opencode's free model hit rate limiting, I've been using workbuddy to polish my 素笺笔记 (Su Jian Notes) project. Today I saw that the C drive was full and turning red. After investigating, .workbuddy took up more than 10 GB of space. If I delete it, the history records are gone; if I don't, it takes too much space. The last time the C drive filled up, the system crashed and I had to reinstall Windows directly. Now I can't tolerate any C drive space pressure at all.
So I used workbuddy itself to build a migration script that moves the migratable content away without affecting daily use.
02 The effort
I originally thought about reinstalling the software myself, but that was too much trouble. So I had workbuddy analyze it, and the files or caches it could delete weren't enough to free up C drive space.
In the era of big data, whatever you want shows up. While reading technical articles, I saw a recommended article and it mentioned that a technique called directory junction (目录联接) could solve this problem.
I didn't understand directory junctions, so I asked the AI whether it could be implemented:
It was obviously feasible. So I just had the AI write a script.
03 Directory Junction
I had to know what a directory junction actually is. I originally thought it was a bit like a docker mount or a shortcut, but after learning about it I found they are not the same thing.
Simply put: a directory junction hangs a "this room has moved, please send things to the new address" forwarding sign on the folder, and this sign is executed by the Windows file system itself, completely invisible to programs.
An analogy: you move a warehouse from drive C to drive E, but don't tell anyone, and only stick a permanent forwarding note at the old door that is handled by the property manager (NTFS). The courier (WorkBuddy) still delivers according to the old address in the contact book, C:\...\.workbuddy\traces. When the courier sees the sign at the door, the package is automatically forwarded to the new warehouse on E. The courier doesn't need to update the address book and doesn't even know the move happened; nothing piles up at the old door except the few-hundred-byte sign.
There are three easily confused points, and they are also the reasons why this is truly useful:
- Program-unaware: The forwarding happens at the file system level, not with application cooperation. The addresses in application logs, configuration, and database don't need a single character changed.
- Always only one copy: This is not synchronization or a backup. There is no copy left on drive C; modifications go to that one copy on drive E.
- The sign itself takes almost no space: A few hundred bytes, and after that all new logs and snapshots grow on drive E, and this location on drive C will not grow again.
For the same reason, it is completely different from the two things we are familiar with:
It is also not the same as container mounts.
A directory junction is a sign carved onto the disk, and whoever looks sees it; a Docker mount is a pair of glasses worn by a container process, and only the wearer sees it, and it disappears when taken off. The former changes the directory itself, while the latter changes the path view of a certain process.
04 Migration Tool
To build the migration tool, and to be able to see what got migrated, I added a graphical interface.
Then I just waited for the result.
4.1 Tool Interface
The interface includes functions such as scan, dry-run, export, verify, rollback, delete backup, and start migration.
4.2 Scan
To prevent files from being occupied during the migration, you need to exit Workbuddy yourself, so the user must confirm by checking a box. After scanning, you can see the status of the files that can be migrated.
4.3 Logs
To make it clear what is being done, the tool also lists the migration checklist, mapping view, execution log, and usage instructions.
4.4 Migration
After the dry-run is complete (or you can skip the dry-run), proceed directly with the migration.
During the migration process, you can watch the progress and also view the execution log.
After migration completes, a migration checklist is presented for confirmation.
After the migration completes, start Workbuddy directly to check whether it works normally. If it does, you can delete the backup. Otherwise, there is no way to free up the C drive.
My original content of more than 10GB was reduced to only 1.25GB after the migration. It really saved a lot of space.
05 Summary
Having AI is really convenient for technologies and languages you don't know. As long as you have an idea, you can implement it. A small migration tool, handled!
Friends who need this tool can help themselves.
Repository address: https://github.com/simonking-ws/workbuddy-migrator
Top 1 of 2 from juejin.cn, machine-translated. The original thread is authoritative.
I can simply choose not to install WorkBuddy.
That works. [grin]