Data Persistence
TIP
Persist
- Persist data by defining the
persistproperty in the manifest. - But it can only persist data within the app installation directory.
- In abyss, the use of
persistis strictly limited.- When data persistence is needed,
linkis preferred. - See: Persist vs Link
- When data persistence is needed,
Refer to: Persist mechanism
Link
- Most modern apps store their data in Windows standard directories, not the installation directory.
C:\Users\<username>\AppData\Roaming\xxxC:\Users\<username>\AppData\Local\xxxC:\Users\<username>\Documents\xxxC:\Users\<username>\xxx- ...
- Since Persist cannot persist these directories, abyss uses the Link mechanism to create file system links at the original data location, associating them with Scoop's persistence directory.
Refer to: Link mechanism
Persist vs Link
Advantages of Link
Unified Link Rules
Scoop's Persist allows customizing target directories. This provides flexibility, but also raises some considerations:
- Which directory should this application's data be placed in?
- What naming format should be used for directories?
- How to maintain consistency across different applications?
Taking some official manifests as examples, you can see they handle things differently.
- extras/bucket/vscode.json
$env:Appdata\Code=>data\Code$home\.vscode=>data\.vscode
- extras/bucket/vscode.json
Some apps are also affected by the limitations of Persist:
In contrast, Link uses unified Link Rules, allowing manifest authors to focus only on the data directories themselves.
- Reduces cognitive load: No need to think about target directory naming and structure.
- Improves consistency: All applications' data directories follow the same rules.
- Facilitates maintenance: Directory structures follow predictable patterns, making management and lookup easier.
Direct Linking vs Indirect Implementation
Since Persist has limitations, official manifests have developed two workarounds to handle apps that store data elsewhere:
Workaround 1: Script-based copy
- Copy data to the installation directory via scripts, then persist.
- Issues:
- Lacks real-time sync: Data synchronization only happens during install and uninstall, not in real-time.
- Increases complexity: Manifest authors need to write additional script logic (e.g.,
Copy-Item).
Workaround 2: Command-line parameters
- Use parameters like
--user-data-dirto redirect data storage. - Issues:
- Update risk: During app updates, the parameter may be ignored or reset, causing data to revert to the default location.
- App-specific: Requires the app to support the specific parameter, limiting applicability.
- Both workarounds are compromises for the limitations of Persist.
- abyss's Link mechanism avoids these issues entirely by creating file system links at the original data location.
- Real-time sync: Data changes are immediately reflected.
- Simple and direct: No additional scripts or parameters needed.
- Standard directory structure: The app always sees the original data directory.
Limitations of Link
Although the Link mechanism solves many issues with Persist, it also has some limitations:
- Backup and migration issues: When backing up Scoop to a new computer, installed apps' data won't have Link
- Command limitations: The
scoop resetcommand cannot be used
TIP
Both of the above limitations can be resolved with the following commands:
scoop update --force <app>to force update the app (recreate the Link)scoop cleanup *to clean up old versions