mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-20 00:18:55 +00:00
fix(plugin): 提交插件包前先关闭 ZIP 读取器
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SAJmqcVA9TLacTCD1bLh4i
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
b7dba62678
commit
335fcdc1d6
@@ -107,7 +107,14 @@ func (i *PluginPackageInstaller) Install(ctx context.Context, reader io.Reader,
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("插件包不是有效的 ZIP: %w", err)
|
||||
}
|
||||
defer func() { _ = archive.Close() }()
|
||||
archiveClosed := false
|
||||
closeArchive := func() {
|
||||
if !archiveClosed {
|
||||
archiveClosed = true
|
||||
_ = archive.Close()
|
||||
}
|
||||
}
|
||||
defer closeArchive()
|
||||
manifest, _, signatureStatus, err := i.inspectArchive(&archive.Reader)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -137,6 +144,8 @@ func (i *PluginPackageInstaller) Install(ctx context.Context, reader io.Reader,
|
||||
if err := i.extractArchive(ctx, &archive.Reader, manifest, extractPath); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Windows 不允许重命名仍被打开的文件,提交前先释放 ZIP 读取器。
|
||||
closeArchive()
|
||||
if err := os.Rename(extractPath, installPath); err != nil {
|
||||
return nil, fmt.Errorf("提交插件安装目录: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user