当前位置: 首页>>代码示例>>Golang>>正文


Golang Storage.RemoveFile方法代码示例

本文整理汇总了Golang中tmsu/storage.Storage.RemoveFile方法的典型用法代码示例。如果您正苦于以下问题:Golang Storage.RemoveFile方法的具体用法?Golang Storage.RemoveFile怎么用?Golang Storage.RemoveFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tmsu/storage.Storage的用法示例。


在下文中一共展示了Storage.RemoveFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: 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
}
开发者ID:kelvinhammond,项目名称:tmsu,代码行数:19,代码来源:repair.go

示例2: removeUntaggedFile

func (command UntagCommand) removeUntaggedFile(store *storage.Storage, file *database.File) error {
	if command.verbose {
		log.Infof("%v: identifying whether file is tagged.", file.Path())
	}

	filetagCount, err := store.FileTagCountByFileId(file.Id)
	if err != nil {
		return fmt.Errorf("%v: could not get tag count: %v", file.Path(), err)
	}

	if filetagCount == 0 {
		if command.verbose {
			log.Infof("%v: removing untagged file.", file.Path())
		}

		err = store.RemoveFile(file.Id)
		if err != nil {
			return fmt.Errorf("%v: could not remove file: %v", file.Path(), err)
		}
	}

	return nil
}
开发者ID:kelvinhammond,项目名称:tmsu,代码行数:23,代码来源:untag.go

示例3: 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
}
开发者ID:kelvinhammond,项目名称:tmsu,代码行数:71,代码来源:delete.go


注:本文中的tmsu/storage.Storage.RemoveFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。