本文整理汇总了Golang中tmsu/storage.Storage.RemoveImplicationsForTagId方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.RemoveImplicationsForTagId方法的具体用法?Golang Storage.RemoveImplicationsForTagId怎么用?Golang Storage.RemoveImplicationsForTagId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tmsu/storage.Storage
的用法示例。
在下文中一共展示了Storage.RemoveImplicationsForTagId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: deleteTag
func (command DeleteCommand) deleteTag(store *storage.Storage, tagName string) error {
tag, err := store.TagByName(tagName)
if err != nil {
return fmt.Errorf("could not retrieve tag '%v': %v", tagName, err)
}
if tag == nil {
return fmt.Errorf("no such tag '%v'.", tagName)
}
if command.verbose {
log.Infof("finding files tagged '%v'.", tagName)
}
fileTags, err := store.FileTagsByTagId(tag.Id)
if err != nil {
return fmt.Errorf("could not retrieve taggings for tag '%v': %v", tagName, err)
}
if command.verbose {
log.Infof("removing applications of tag '%v'.", tagName)
}
err = store.RemoveFileTagsByTagId(tag.Id)
if err != nil {
return fmt.Errorf("could not remove taggings for tag '%v': %v", tagName, err)
}
if command.verbose {
log.Infof("removing tags implications involving tag '%v'.", tagName)
}
err = store.RemoveImplicationsForTagId(tag.Id)
if err != nil {
return fmt.Errorf("could not remove tag implications involving tag '%v': %v", tagName, err)
}
if command.verbose {
log.Infof("deleting tag '%v'.", tagName)
}
err = store.DeleteTag(tag.Id)
if err != nil {
return fmt.Errorf("could not delete tag '%v': %v", tagName, err)
}
if command.verbose {
log.Infof("identifying files left untagged as a result of tag deletion.")
}
removedFileCount := 0
for _, fileTag := range fileTags {
count, err := store.FileTagCountByFileId(fileTag.FileId)
if err != nil {
return fmt.Errorf("could not retrieve taggings count for file #%v: %v", fileTag.FileId, err)
}
if count == 0 {
err := store.RemoveFile(fileTag.FileId)
if err != nil {
return fmt.Errorf("could not remove file #%v: %v", fileTag.FileId, err)
}
removedFileCount += 1
}
}
if command.verbose {
log.Infof("removed %v untagged files.", removedFileCount)
}
return nil
}