예제 #1
0
파일: filetag.go 프로젝트: peer23peer/TMSU
// 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
}
예제 #2
0
파일: filetag.go 프로젝트: peer23peer/TMSU
// 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
}