anchor.diff:        after
           ok = file:close(Fd)
         end,
  -      init_ets_from_index_files(Tid, Rest);
  -    {error, Reason} ->
  -      file:close(Fd),
  -      erlang:error(Reason)
  +      init_ets_from_index_files(Tid, Rest)
     end.
   
   -spec init_ets_from_index_file(logvsn(), cache(), segid(), file:fd()) -> ok | no_return().
  
positive.code: -spec switch(dirname(), index(), logid()) -> index().
  switch(Dir, #idx{fd = Fd} = Idx, NextLogId) ->
    NewSegId = NextLogId,
    {?LOGVSN, NewFd} = open_writer_fd(_IsNew = true, mk_name(Dir, NewSegId)),
    ok = file_sync_close(Fd),
    Idx#idx{segid = NewSegId, fd = NewFd}.
  
  %% @doc Switch to a new log segment, append new index entry.
  
negative.code: open_writer_fd(false, FileName) ->
    {ok, Fd} = file:open(FileName, [write, read, raw, binary]),
    %% read two bytes instead of 1
    {ok, <<Version:8>>} = file:read(Fd, 1),
    %% more than the version byte
    {ok, Position} = file:position(Fd, eof),
    %% Hopefully, this assertion never fails,
    %% In case it happens, add a function to resect the corrupted tail.
    0 = (Position - 1) rem file_entry_bytes(Version), %% assert
    {Version, Fd}.
  
  %% @private Get per-version file entry bytes.
  -spec file_entry_bytes(logvsn()) -> bytecnt().
  