huiyadanli/RevokeMsgPatcher · error · DirectoryNotFoundException

源目录不存在: {sourceDirName}

Error message

源目录不存在: {sourceDirName}

What it means

DirectoryCopy throws DirectoryNotFoundException when the source directory does not exist. It is called after zip extraction with pluginPath = FindDirectoryWithJson(extractPath); if that returned null (no package.json/manifest.json found within depth 2), copying from a null/non-existent path throws.

Source

Thrown at RevokeMsgPatcher/Model/LiteLoaderRowData.cs:307

                    Directory.CreateDirectory(localDirectory); // 确保目录存在
                    File.WriteAllBytes(localPath, data);
                    return localPath;
                }
                else
                {
                    throw new Exception("下载失败");
                }
            }
        }

        private void DirectoryCopy(string sourceDirName, string destDirName, bool copySubDirs = true)
        {
            DirectoryInfo dir = new DirectoryInfo(sourceDirName);
            DirectoryInfo[] dirs = dir.GetDirectories();

            if (!dir.Exists)
            {
                throw new DirectoryNotFoundException("源目录不存在: " + sourceDirName);
            }

            if (!Directory.Exists(destDirName))
            {
                Directory.CreateDirectory(destDirName);
            }

            FileInfo[] files = dir.GetFiles();
            foreach (FileInfo file in files)
            {
                string tempPath = Path.Combine(destDirName, file.Name);
                file.CopyTo(tempPath, true);
            }

            if (copySubDirs)
            {
                foreach (DirectoryInfo subdir in dirs)
                {

View on GitHub (pinned to 89cbbb3f0c)

Solutions

  1. Re-download the package (click Update again) in case of a truncated archive.
  2. If it persists, the plugin's zip layout changed; report it or raise FindDirectoryWithJson's maxDepth / add the new manifest filename.
Defensive patterns

Strategy: try-catch

Validate before calling

string pluginPath = FindDirectoryWithJson(extractPath);
if (pluginPath == null || !Directory.Exists(pluginPath))
{
    UpdateStatus("解压后未找到插件目录,请重新下载。");
    Directory.Delete(extractPath, true);
    return;
}

Try / catch

try
{
    DirectoryCopy(pluginPath, LocalPath);
}
catch (DirectoryNotFoundException)
{
    UpdateStatus("源目录不存在,请重新下载并重试。");
}

Prevention

When it happens

Trigger: The downloaded zip extracted without a package.json/manifest.json at depth <= 2, so FindDirectoryWithJson returned null and DirectoryCopy(null,...) failed; or the zip layout changed / download was truncated.

Common situations: Plugin repo changed its archive structure; a corrupted or partial download produced an unexpected directory tree.

Related errors


AI-assisted analysis of huiyadanli/RevokeMsgPatcher@89cbbb3f0c (2026-08-13). Data as JSON: /api/errors/4ca9b307817e0bc8. Report an issue: GitHub.