本文整理匯總了Golang中tmsu/storage.Storage.RemoveFileTagsByFileId方法的典型用法代碼示例。如果您正苦於以下問題:Golang Storage.RemoveFileTagsByFileId方法的具體用法?Golang Storage.RemoveFileTagsByFileId怎麽用?Golang Storage.RemoveFileTagsByFileId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tmsu/storage.Storage
的用法示例。
在下文中一共展示了Storage.RemoveFileTagsByFileId方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: untagPathAll
func (command UntagCommand) untagPathAll(store *storage.Storage, path string) error {
absPath, err := filepath.Abs(path)
if err != nil {
return fmt.Errorf("%v: could not get absolute path: %v", path, err)
}
file, err := store.FileByPath(absPath)
if err != nil {
return fmt.Errorf("%v: could not retrieve file: %v", path, err)
}
if file == nil {
return fmt.Errorf("%v: file is not tagged.", path)
}
if command.verbose {
log.Infof("%v: removing all tags.", file.Path())
}
if err := store.RemoveFileTagsByFileId(file.Id); err != nil {
return fmt.Errorf("%v: could not remove file's tags: %v", file.Path(), err)
}
if err := command.removeUntaggedFile(store, file); err != nil {
return err
}
if command.recursive {
childFiles, err := store.FilesByDirectory(file.Path())
if err != nil {
return fmt.Errorf("%v: could not retrieve files for directory: %v", file.Path())
}
for _, childFile := range childFiles {
if err := store.RemoveFileTagsByFileId(childFile.Id); err != nil {
return fmt.Errorf("%v: could not remove file's tags: %v", childFile.Path(), err)
}
if err := command.removeUntaggedFile(store, childFile); err != nil {
return err
}
}
}
return nil
}
示例2: repairMissing
func (command RepairCommand) repairMissing(store *storage.Storage, missing databaseFileMap) error {
for path, dbFile := range missing {
if command.force && !command.pretend {
if err := store.RemoveFileTagsByFileId(dbFile.Id); err != nil {
return fmt.Errorf("%v: could not delete file-tags: %v", path, err)
}
if err := store.RemoveFile(dbFile.Id); err != nil {
return fmt.Errorf("%v: could not delete file: %v", path, err)
}
log.Infof("%v: removed", path)
} else {
log.Infof("%v: missing", path)
}
}
return nil
}