Example #1
0
// Retrieves the file tags with the specified tag ID.
func (storage *Storage) FileTagsByTagId(tx *Tx, tagId entities.TagId, explicitOnly bool) (entities.FileTags, error) {
	fileTags, err := database.FileTagsByTagId(tx.tx, tagId)
	if err != nil {
		return nil, err
	}

	if !explicitOnly {
		var err error
		fileTags, err = storage.addImpliedFileTags(tx, fileTags)
		if err != nil {
			return nil, err
		}
	}

	return fileTags, nil
}
Example #2
0
// Deletes all of the file tags for the specified tag.
func (storage *Storage) DeleteFileTagsByTagId(tx *Tx, tagId entities.TagId) error {
	fileTags, err := database.FileTagsByTagId(tx.tx, tagId)
	if err != nil {
		return err
	}

	if err := database.DeleteFileTagsByTagId(tx.tx, tagId); err != nil {
		return err
	}

	if err := storage.DeleteUntaggedFiles(tx, fileTags.FileIds()); err != nil {
		return err
	}

	return nil
}