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
- Re-download the package (click Update again) in case of a truncated archive.
- 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
- Validate FindDirectoryWithJson's result before copying.
- Re-download on a null plugin path rather than letting DirectoryCopy throw.
- If a plugin repo changes its archive layout, update FindDirectoryWithJson depth/filenames.
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
- 下载失败
- 在路径{appPath}下,未找到package.json.h.bak备份文件,请确认是否通过本软件安装过 LiteLo
- 在路径{appPath}下,未找到app_launcher文件夹
- 在路径{appPath}下,未找到package.json文件
AI-assisted analysis of huiyadanli/RevokeMsgPatcher@89cbbb3f0c (2026-08-13).
Data as JSON: /api/errors/4ca9b307817e0bc8.
Report an issue: GitHub.