Skip to content

[Bug]: Upgrading to 5.0 will re-run sqlite import even if previously imported, deleting all existing data #727

@hmhackmaster

Description

@hmhackmaster

Describe the bug

TL;DR: Data loss will occur if you leave `massCode.db

It looks like the first-run of 5.0 checks if the massCode.db SQLite db still exists and, if so, will run the import/conversion to the Markdown file storage schema.

It does not check if this import/conversion was previously run and will delete anything in the .\markdown-vault folder.

In my case, I completed the import on version 4.7.1; for whatever reason my massCode.db file remained in my massCode data folder:

.\masscode\massCode.db
.\masscode\markdown-vault\.masscode\state.json
.\masscode\markdown-vault\PowerShell\.masscode-folder.yml
.\masscode\markdown-vault\PowerShell\Convert Masscode Snippets to Windows Terminal Snippets.md
[etc...]

My .\markdown-vault folder was completely wiped (without any user prompt or alert) and all additions and modifications to snippets that were done after migrating from the SQLite database format were completely lost.

My folder structure now looks like:

.\masscode\massCode.db
.\masscode\markdown-vault\code\.masscode\state.json
.\masscode\markdown-vault\code\PowerShell\Old-out-of-date-snippet.md
.\masscode\markdown-vault\notes\.masscode\state.json
[etc...]

To reproduce

My lifecycle steps:

  1. Install massCode version 4.4.0 (defaults to SQLite for the data storage format)
  2. Add new snippets
  3. Install massCode version 4.7.1
  4. Add/modify/delete snippets
  5. Manually convert from SQLite to Markdown data storage format using settings option
  6. Add/modify/delete snippets
  7. Install massCode 5.0.0
  8. Find all snippet changes since step 4 are lost

My test repo steps:

After installing massCode 5.0.0

  1. Quit massCode
  2. Restore .\masscode\markdown-vault folder to pre-5.0.0 state
  3. Confirm .\masscode\assCode.db still exists (this file has remained in place and unmodified since my initial upgrade)
  4. Launch massCode 5.0.0
  5. Observe masscode.exe open and access .\masscode\massCode.db
  6. Observe masscode.exe move files from .\masscode\markdown-vault\EXAMPLE-NEW-DIR\EXAMPLE-NEW-SNIPPET.md to .\masscode\markdown-vault\code\EXAMPLE-NEW-DIR\EXAMPLE-NEW-SNIPPET.md
  7. Observe masscode.exe delete file .\masscode\markdown-vault\code\EXAMPLE-NEW-DIR\EXAMPLE-NEW-SNIPPET.md
  8. Observe masscode.exe create file .\masscode\markdown-vault\code\EXAMPLE-OLD-DIR\EXAMPLE-OLD-SNIPPET.md
    File actions were observed & confirmed via OS-level process monitoring

App Version and Architecture

5.0.0

System info

Windows 11

Validations

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions