docs: def write(self):
          """Safely write the index data to the index file """
          index_file = self.path
          new_index_file = index_file + '.new'
          bak_index_file = index_file + '.bak'
  
          if not self._db:
              return
  
          with open(new_index_file, 'w') as f:
              json.dump(self._db, f, indent=4)
  
          if exists(index_file):
              copy(index_file, bak_index_file)
  
          rename(new_index_file, index_file)