fix(windows): observe settled claim loss
This commit is contained in:
@@ -955,6 +955,23 @@ func windowsRelativeClaimAbsentOrOrphan(directory *windowsPrivateDirectory, sour
|
||||
|
||||
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(
|
||||
directory windows.Handle,
|
||||
name string,
|
||||
@@ -988,12 +1005,8 @@ func (directory *windowsPrivateDirectory) ClaimRegular(source, claim string) (bo
|
||||
1,
|
||||
)
|
||||
if err != nil {
|
||||
pair, pairErr := windowsRelativeClaimPairExists(directory, source, claim)
|
||||
if pairErr == nil && pair {
|
||||
return false, nil
|
||||
}
|
||||
orphan, orphanErr := windowsRelativeClaimAbsentOrOrphan(directory, source, claim)
|
||||
if orphanErr == nil && orphan {
|
||||
lost, observationErr := waitForWindowsRelativeClaimLoss(directory, source, claim)
|
||||
if observationErr == nil && lost {
|
||||
return false, nil
|
||||
}
|
||||
return false, ErrUnsafeFile
|
||||
|
||||
Reference in New Issue
Block a user