Migrate from ChatTwo layout at file level, not directory level

The original migration skipped the database move whenever
pluginConfigs/HellionChat already existed. In practice that
directory is materialised by Dalamud before our plugin constructor
runs, so the check was effectively always true and the legacy
chat-sqlite.db plus the EmoteCacheV1 directory stayed behind.

Walk the legacy directory entry by entry instead. Move every file
or subdirectory whose name is not already present on the target
side, then delete the legacy directory if it ends up empty. This
handles both fresh installs and the realistic case where Dalamud
has pre-created an empty config directory for the new plugin.
This commit is contained in:
2026-05-01 18:40:06 +02:00
parent 2401ea5864
commit f0d6d64666
+31 -3
View File
@@ -265,10 +265,38 @@ public sealed class Plugin : IDalamudPlugin
Log.Information($"HellionChat: migrated config file {legacyConfigFile} → {ourConfigFile}");
}
if (!Directory.Exists(ourConfigDir) && Directory.Exists(legacyConfigDir))
// The plugin's ConfigDirectory may already exist on first load
// (Dalamud creates it), so check at the file level instead of
// skipping when the directory is present. Move every legacy
// entry whose target name is not occupied yet, then remove the
// source dir if it ends up empty.
if (Directory.Exists(legacyConfigDir))
{
Directory.Move(legacyConfigDir, ourConfigDir);
Log.Information($"HellionChat: migrated config dir {legacyConfigDir} → {ourConfigDir}");
Directory.CreateDirectory(ourConfigDir);
foreach (var file in Directory.EnumerateFiles(legacyConfigDir))
{
var target = Path.Combine(ourConfigDir, Path.GetFileName(file));
if (File.Exists(target))
continue;
File.Move(file, target);
Log.Information($"HellionChat: migrated file {file} → {target}");
}
foreach (var dir in Directory.EnumerateDirectories(legacyConfigDir))
{
var target = Path.Combine(ourConfigDir, Path.GetFileName(dir));
if (Directory.Exists(target))
continue;
Directory.Move(dir, target);
Log.Information($"HellionChat: migrated subdir {dir} → {target}");
}
if (!Directory.EnumerateFileSystemEntries(legacyConfigDir).Any())
{
Directory.Delete(legacyConfigDir);
Log.Information($"HellionChat: removed empty legacy dir {legacyConfigDir}");
}
}
}
catch (Exception e)