MCPcopy Create free account
hub / github.com/OpenListTeam/OpenList / GetDirectUploadInfo

Function GetDirectUploadInfo

internal/op/fs.go:782–815  ·  view source on GitHub ↗
(ctx context.Context, tool string, storage driver.Driver, dstDirPath, dstName string, fileSize int64, overwrite bool)

Source from the content-addressed store, hash-verified

780}
781
782func 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
817func objsUpdateHook(ctx context.Context, storage driver.Driver, dirPath string, recursive bool) {
818 files, err := List(ctx, storage, dirPath, model.ListArgs{SkipHook: true})

Callers 2

getDirectUploadInfoFunction · 0.92
directUploadURLFunction · 0.92

Calls 8

FixAndCleanPathFunction · 0.92
IsObjectNotFoundFunction · 0.92
GetUnwrapFunction · 0.85
GetFunction · 0.70
MakeDirFunction · 0.70
ConfigMethod · 0.65
GetStorageMethod · 0.65
GetDirectUploadInfoMethod · 0.65

Tested by

no test coverage detected