code: func (ts *Store) remove(id string) error {
  	treepath := ts.GetPath(id)
  	// If tree path doesn't exist we're done
  	_, err := os.Stat(treepath)
  	if err != nil && os.IsNotExist(err) {
  		return nil
  	}
  	if err != nil {
  		return errwrap.Wrap(errors.New("failed to open tree store directory"), err)
  	}
  
  	renderedFilePath := filepath.Join(treepath, renderedfilename)
  	// The "rendered" flag file should be the firstly removed file. So if
  	// the removal ends with some error leaving some stale files IsRendered()
  	// will return false.
  	_, err = os.Stat(renderedFilePath)
  	if err != nil && !os.IsNotExist(err) {
  		return err
  	}
  	if !os.IsNotExist(err) {
  		err := os.Remove(renderedFilePath)
  		// Ensure that the treepath directory is fsynced after removing the
  		// "rendered" flag file
  		f, err := os.Open(treepath)
  		if err != nil {
  			return errwrap.Wrap(errors.New("failed to open tree store directory"), err)
  		}
  		defer f.Close()
  		err = f.Sync()
  		if err != nil {
  			return errwrap.Wrap(errors.New("failed to sync tree store directory"), err)
  		}
  	}
  
  	// Ignore error retrieving image hash
  	key, _ := ts.GetImageHash(id)
  
  	if err := os.RemoveAll(treepath); err != nil {
  		return err
  	}
  
  	if key != "" {
  		return ts.store.UpdateTreeStoreSize(key, 0)
  	}
  
  	return nil
  }
docs: // remove cleans the directory for the provided id