Migrate note storage from Registry to file system#5
Merged
Conversation
根本原因:_DefaultSettings 注册表项被当作便签数据处理 - OPENED_NOTES 过滤掉以下划线开头的特殊键,避免 _DefaultSettings 被加载为便签 - DeleteAll() 保留特殊键,防止默认设置在重启时被误删 - LoadData 添加 _isLoading 标志,防止加载过程中 Title setter 用未初始化的 theme=0/style=0 提前写入注册表 - LoadData 直接设置 _theme/_style 字段并调用 ReloadTheme/ReloadStyle,避免 setter 副作用 - 安装器 MajorUpgrade Schedule 改为 afterInstallInitialize 确保覆盖升级顺序正确 - CustomAction 添加条件 NOT REMOVE~="ALL",卸载时不启动程序 https://claude.ai/code/session_01C8uHLbTTSPExtKZ7pNi56j
- 便签数据存储到 %AppData%\Desktop_Notes\notes\{id}.json
- 默认设置存储到 %AppData%\Desktop_Notes\_DefaultSettings.json
- 启动时自动检测注册表中的存量数据并迁移到文件目录
- 迁移完成后清理注册表中的旧数据和空键
- StartWithWindows 和 FirstRun 仍使用注册表(属于系统级设置)
- 保持 REGISTRY 类的公共 API 不变,所有调用方无需修改
https://claude.ai/code/session_01C8uHLbTTSPExtKZ7pNi56j
- Custom 元素的条件从 inner text 改为 Condition 属性(WIX0400) - DesktopFolder 从 DirectoryRef 改为 StandardDirectory(WIX5436) - 移除顶部重复的 StandardDirectory DesktopFolder 声明 - RemoveFolder Id 改名避免与 StandardDirectory Id 冲突 https://claude.ai/code/session_01C8uHLbTTSPExtKZ7pNi56j
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR migrates the Desktop Notes application from storing note data in the Windows Registry to a file-based storage system in the AppData directory, while maintaining backward compatibility with existing user data.
Key Changes
REGISTRY.cs
HKEY_CURRENT_USER\Software\Sand Soft\Desktop Notesto%AppData%\Desktop_Notes\notes\%AppData%\Desktop_Notes\- Main data directory%AppData%\Desktop_Notes\notes\- Individual note files (JSON format)%AppData%\Desktop_Notes\_DefaultSettings.json- Default note settingsMigrateFromRegistry()method that automatically detects and migrates existing Registry data to the new file-based storage on first runSaveDefaultSettings()andGetDefaultSettings()from Registry to file-based storageMainForm.cs
_isLoadingflag to prevent saving during form initialization_theme,_style) with proper validationSave()method to skip saving while form is loading to prevent data corruptionLoadData()in try-finally block to ensure_isLoadingflag is properly resetProduct.wxs
MajorUpgradeschedule fromafterInstallExecutetoafterInstallInitializefor more reliable upgradesImplementation Details
https://claude.ai/code/session_01C8uHLbTTSPExtKZ7pNi56j