fix(windows): observe settled claim loss
This commit is contained in:
@@ -955,6 +955,23 @@ func windowsRelativeClaimAbsentOrOrphan(directory *windowsPrivateDirectory, sour
|
|||||||
|
|
||||||
const windowsClaimSharingRetries = 100
|
const windowsClaimSharingRetries = 100
|
||||||
|
|
||||||
|
func waitForWindowsRelativeClaimLoss(directory *windowsPrivateDirectory, source, claim string) (bool, error) {
|
||||||
|
for attempt := 0; ; attempt++ {
|
||||||
|
pair, pairErr := windowsRelativeClaimPairExists(directory, source, claim)
|
||||||
|
if pairErr == nil && pair {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
absent, absentErr := windowsRelativeClaimAbsentOrOrphan(directory, source, claim)
|
||||||
|
if absentErr == nil && absent {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
if attempt == windowsClaimSharingRetries {
|
||||||
|
return false, ErrUnsafeFile
|
||||||
|
}
|
||||||
|
time.Sleep(time.Millisecond)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func openWindowsPrivateClaimRegular(
|
func openWindowsPrivateClaimRegular(
|
||||||
directory windows.Handle,
|
directory windows.Handle,
|
||||||
name string,
|
name string,
|
||||||
@@ -988,12 +1005,8 @@ func (directory *windowsPrivateDirectory) ClaimRegular(source, claim string) (bo
|
|||||||
1,
|
1,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
pair, pairErr := windowsRelativeClaimPairExists(directory, source, claim)
|
lost, observationErr := waitForWindowsRelativeClaimLoss(directory, source, claim)
|
||||||
if pairErr == nil && pair {
|
if observationErr == nil && lost {
|
||||||
return false, nil
|
|
||||||
}
|
|
||||||
orphan, orphanErr := windowsRelativeClaimAbsentOrOrphan(directory, source, claim)
|
|
||||||
if orphanErr == nil && orphan {
|
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
return false, ErrUnsafeFile
|
return false, ErrUnsafeFile
|
||||||
|
|||||||
Reference in New Issue
Block a user