fix(skills): compare Windows publication identity stably
This commit is contained in:
1 parent
dd89c67f4d
commit
16d20b8178
5 files changed
+19
-6
No files matched your search
@@ -42,12 +42,9 @@ func PublishSkillPathNoReplace(staged, destination string) (SkillPathPublication
|
||||
if err != nil {
|
||||
return SkillPathPublication{}, fmt.Errorf("确认已发布 Skill 内容失败 %s(对象保留): %w", destination, err)
|
||||
}
|
||||
// Force os.SameFile to resolve and cache any path-backed identity (notably
|
||||
// on Windows) while the just-published object is known to occupy the path.
|
||||
if !os.SameFile(identity, publishedIdentity) || publishedFingerprint != fingerprint {
|
||||
if !skillPathSameFileIdentity(identity, publishedIdentity) || publishedFingerprint != fingerprint {
|
||||
return SkillPathPublication{}, fmt.Errorf("确认已发布 Skill 身份失败 %s(对象保留): staging 身份已变化", destination)
|
||||
}
|
||||
_ = os.SameFile(publishedIdentity, publishedIdentity)
|
||||
return SkillPathPublication{
|
||||
Destination: destination,
|
||||
fingerprint: fingerprint,
|
||||
@@ -96,7 +93,7 @@ func rollbackSkillPathPublication(publication SkillPathPublication) (err error)
|
||||
cleanupRoot(),
|
||||
)
|
||||
}
|
||||
if publication.identity == nil || !os.SameFile(publication.identity, liveIdentity) ||
|
||||
if publication.identity == nil || !skillPathSameFileIdentity(publication.identity, liveIdentity) ||
|
||||
publication.incarnation != skillPathFileIncarnation(liveIdentity) ||
|
||||
liveFingerprint != publication.fingerprint {
|
||||
return errors.Join(
|
||||
@@ -116,7 +113,7 @@ func rollbackSkillPathPublication(publication SkillPathPublication) (err error)
|
||||
actualIdentity, identityErr := skillPathLstat(quarantine)
|
||||
actual, fingerprintErr := fingerprintSkillPath(quarantine)
|
||||
if identityErr == nil && fingerprintErr == nil &&
|
||||
os.SameFile(publication.identity, actualIdentity) &&
|
||||
skillPathSameFileIdentity(publication.identity, actualIdentity) &&
|
||||
actual == publication.fingerprint {
|
||||
if removeErr := removePublishedSkillSource(quarantine); removeErr != nil {
|
||||
return fmt.Errorf("移除事务发布的 Skill 失败 %s(隔离于 %s): %w", destination, quarantine, removeErr)
|
||||
|
||||
Reference in new issue
Block a user