Skip to content

Data Persistence

TIP

  • One of Scoop's most powerful features is data persistence: retaining user data when uninstalling apps, and automatically restoring it upon reinstall.
  • abyss uses Persist + Link, with Link as the primary approach.

Persist

  • Persist data by defining the persist property in the manifest.
  • But it can only persist data within the app installation directory.
  • In abyss, the use of persist is strictly limited.

Refer to: Persist mechanism

  • Most modern apps store their data in Windows standard directories, not the installation directory.
    • C:\Users\<username>\AppData\Roaming\xxx
    • C:\Users\<username>\AppData\Local\xxx
    • C:\Users\<username>\Documents\xxx
    • C:\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

  • 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.

  • 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-dir to 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.

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 reset command cannot be used

TIP

Both of the above limitations can be resolved with the following commands:

  1. scoop update --force <app> to force update the app (recreate the Link)
  2. scoop cleanup * to clean up old versions

abyss — always building your stable source.
Released under the MIT.