code: def remove_unused_links(self, used):
          
          unused = []
  
          self._execute("SELECT * FROM {}".format(self.LINK_STATE_TABLE))
          for row in self.cursor:
              relpath, inode, mtime = row
              inode = self._from_sqlite(inode)
              path = os.path.join(self.root_dir, relpath)
  
              if path in used:
                  continue
  
              if not os.path.exists(path):
                  continue
  
              actual_inode = get_inode(path)
              actual_mtime, _ = get_mtime_and_size(path)
  
              if inode == actual_inode and mtime == actual_mtime:
                  logger.debug("Removing '{}' as unused link.".format(path))
                  remove(path)
                  unused.append(relpath)
  
          for relpath in unused:
              cmd = 'DELETE FROM {} WHERE path = "{}"'
              self._execute(cmd.format(self.LINK_STATE_TABLE, relpath))
docs: Removes all saved links except the ones that are used.
  
          Args:
              used (list): list of used links that should not be removed.