anchor.diff:      end.
   
   handle_info({Ref, _}, {sync, SyncInterval}) ->
  -   bitcask:sync(Ref),
  +    bitcask:sync(Ref),
       erlang:send_after(SyncInterval, self(),
                         {?MODULE, {sync, SyncInterval}});
  -handle_info({_, BitcaskRoot}, {merge, MergeInterval}) ->
  -    bitcask_merge_worker:merge(BitcaskRoot),
  -    erlang:send_after(MergeInterval, self(),
  -                      {?MODULE, {merge, MergeInterval}}).
  +
  +handle_info({Ref, BitcaskRoot}, merge_check) ->
  +    case bitcask:needs_merge(Ref) of
  +        {true, Files} ->
  +            bitcask_merge_worker:merge(BitcaskRoot, [], Files);
  +        false ->
  +            ok
  +    end,
  +    erlang:send_after(?MERGE_CHECK_INTERVAL, self(), {?MODULE, merge_check}).
   
   
   %% ===================================================================
  
positive.code:             ok
      end,
  
      %% Schedule merges
      case application:get_env(bitcask, merge_strategy) of
          {ok, {hours, Hours}} ->
              MergeIntervalMs = timer:hours(Hours),
              erlang:send_after(MergeIntervalMs, self(),
                                {?MODULE, {merge, MergeIntervalMs}});
          undefined ->
              undefined
      end,
  
      %% Get the data root directory
      DataDir =
  
negative.code: -include_lib("eunit/include/eunit.hrl").
  -endif.
  
  -define(MERGE_CHECK_INTERVAL, timer:minutes(3)).
  
  start(Partition, _Config) ->
      %% Schedule sync (if necessary)
      case application:get_env(bitcask, sync_strategy) of
  