You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

utils.go 631 B

1234567891011121314151617181920212223242526
  1. package utils
  2. import "gitlink.org.cn/cloudream/storage/common/pkgs/storage/types"
  3. type errorShardWriter struct {
  4. err error
  5. }
  6. func (w *errorShardWriter) Write(data []byte) (int, error) {
  7. return 0, w.err
  8. }
  9. // 取消写入。要求允许在调用了Finish之后再调用此函数,且此时不应该有任何影响。
  10. // 方便defer机制
  11. func (w *errorShardWriter) Abort() error {
  12. return w.err
  13. }
  14. // 结束写入,获得文件哈希值
  15. func (w *errorShardWriter) Finish() (types.FileInfo, error) {
  16. return types.FileInfo{}, w.err
  17. }
  18. func ErrorShardWriter(err error) types.ShardWriter {
  19. return &errorShardWriter{err: err}
  20. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。