DoRE:
PROC = {
expungePosToUse: INT ← expungeLogLength;
le: LogEntry;
keyFromExpLog: REF TEXT;
internalFileIDFromExpLog, logSeqNoFromExpLog: INT;
reason: FS.ErrorDesc;
BEGIN
ENABLE
BEGIN
FS.Error => { reason ← error; GOTO error };
IO.Error => { reason ← AlpineFS.ErrorFromStream[stream]; GOTO error };
UNWIND => { currentStream ← expungeStream ← NIL };
END;
ok ← FALSE;
[currentStream, expungeStream, keyIs, expungeInternalFileID, logSeqNo] ←
WalnutRoot.GetStreamsForExpunge[];
IF expungeStream = NIL THEN RETURN;
IF expungeStream.GetLength[] < expungeLogLength THEN RETURN; -- too short
expungeStream.SetIndex[0];
le ← WalnutStream.ReadEntry[expungeStream].le;
IF le = NIL THEN RETURN;
TRUSTED {
WITH le: le
SELECT
FROM
LogFileInfo => {
keyFromExpLog ← le.key;
internalFileIDFromExpLog ← le.internalFileID;
logSeqNoFromExpLog ← le.logSeqNo;
};
ENDCASE => RETURN;
};
IF expungeLogLength = 0 THEN expungePosToUse ← expungeStream.GetIndex[];
IF ~keyIs.Equal[RefText.TrustTextAsRope[keyFromExpLog]] THEN RETURN;
IF internalFileIDFromExpLog # expungeInternalFileID THEN RETURN;
IF logSeqNoFromExpLog # logSeqNo THEN RETURN;
WalnutStream.SetHighWaterMark[expungeStream, expungePosToUse, -1];
expungeStream.SetIndex[expungePosToUse];
currentStream.SetIndex[currentLogPos];
currentEntryLengthHint ← -1;
currentEntryPos ← currentLogPos;
ok ←
TRUE;
EXITS error => {
WalnutRoot.StatsReport["\n *** During Start Expunge "];
WalnutRoot.StatsReport[reason.explanation];
ok ← FALSE;
};
END;
};