(ctx context.Context, tool string, storage driver.Driver, dstDirPath, dstName string, fileSize int64, overwrite bool)
| 780 | } |
| 781 | |
| 782 | func GetDirectUploadInfo(ctx context.Context, tool string, storage driver.Driver, dstDirPath, dstName string, fileSize int64, overwrite bool) (any, error) { |
| 783 | du, ok := storage.(driver.DirectUploader) |
| 784 | if !ok { |
| 785 | return nil, errors.WithStack(errs.NotImplement) |
| 786 | } |
| 787 | if storage.Config().CheckStatus && storage.GetStorage().Status != WORK { |
| 788 | return nil, errors.WithMessagef(errs.StorageNotInit, "storage status: %s", storage.GetStorage().Status) |
| 789 | } |
| 790 | dstDirPath = utils.FixAndCleanPath(dstDirPath) |
| 791 | dstPath := stdpath.Join(dstDirPath, dstName) |
| 792 | var err error |
| 793 | if !overwrite { |
| 794 | _, err = Get(ctx, storage, dstPath) |
| 795 | if err == nil { |
| 796 | return nil, errors.WithStack(errs.ObjectAlreadyExists) |
| 797 | } |
| 798 | if !errs.IsObjectNotFound(err) { |
| 799 | return nil, errors.WithMessage(err, "failed to check if object exists") |
| 800 | } |
| 801 | } |
| 802 | err = MakeDir(ctx, storage, dstDirPath) |
| 803 | if err != nil { |
| 804 | return nil, errors.WithMessagef(err, "failed to make dir [%s]", dstDirPath) |
| 805 | } |
| 806 | dstDir, err := GetUnwrap(ctx, storage, dstDirPath) |
| 807 | if err != nil { |
| 808 | return nil, errors.WithMessagef(err, "failed to get dir [%s]", dstDirPath) |
| 809 | } |
| 810 | info, err := du.GetDirectUploadInfo(ctx, tool, dstDir, dstName, fileSize) |
| 811 | if err != nil { |
| 812 | return nil, errors.WithStack(err) |
| 813 | } |
| 814 | return info, nil |
| 815 | } |
| 816 | |
| 817 | func objsUpdateHook(ctx context.Context, storage driver.Driver, dirPath string, recursive bool) { |
| 818 | files, err := List(ctx, storage, dirPath, model.ListArgs{SkipHook: true}) |
no test coverage detected