MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / Set

Method Set

service/explorer/entity.go:65–86  ·  view source on GitHub ↗

Set sets the current version of the file

(c *gin.Context)

Source from the content-addressed store, hash-verified

63
64// Set sets the current version of the file
65func (s *SetCurrentVersionService) Set(c *gin.Context) error {
66 dep := dependency.FromContext(c)
67 user := inventory.UserFromContext(c)
68 m := manager.NewFileManager(dep, user)
69 defer m.Recycle()
70
71 uri, err := fs.NewUriFromString(s.Uri)
72 if err != nil {
73 return serializer.NewError(serializer.CodeParamErr, "unknown uri", err)
74 }
75
76 versionId, err := dep.HashIDEncoder().Decode(s.Version, hashid.EntityID)
77 if err != nil {
78 return serializer.NewError(serializer.CodeParamErr, "unknown version id", err)
79 }
80
81 if err := m.SetCurrentVersion(c, uri, versionId); err != nil {
82 return fmt.Errorf("failed to set current version: %w", err)
83 }
84
85 return nil
86}
87
88type (
89 DeleteVersionParamCtx struct{}

Callers

nothing calls this directly

Calls 9

RecycleMethod · 0.95
FromContextFunction · 0.92
UserFromContextFunction · 0.92
NewFileManagerFunction · 0.92
NewUriFromStringFunction · 0.92
NewErrorFunction · 0.92
DecodeMethod · 0.65
HashIDEncoderMethod · 0.65
SetCurrentVersionMethod · 0.65

Tested by

no test coverage detected