MCPcopy
hub / github.com/cloudreve/cloudreve / CreateDirectLink

Method CreateDirectLink

inventory/file.go:380–398  ·  view source on GitHub ↗
(ctx context.Context, file int, name string, speed int, reuse bool)

Source from the content-addressed store, hash-verified

378}
379
380func (f *fileClient) CreateDirectLink(ctx context.Context, file int, name string, speed int, reuse bool) (*ent.DirectLink, error) {
381 if reuse {
382 // Find existed
383 existed, err := f.client.DirectLink.
384 Query().
385 Where(directlink.FileID(file), directlink.Name(name), directlink.Speed(speed)).First(ctx)
386 if err == nil {
387 return existed, nil
388 }
389 }
390
391 return f.client.DirectLink.
392 Create().
393 SetFileID(file).
394 SetName(name).
395 SetSpeed(speed).
396 SetDownloads(0).
397 Save(ctx)
398}
399
400func (f *fileClient) GetByHashID(ctx context.Context, hashID string) (*ent.File, error) {
401 id, err := f.hasher.Decode(hashID, hashid.FileID)

Callers

nothing calls this directly

Calls 12

FileIDFunction · 0.92
NameFunction · 0.92
SpeedFunction · 0.92
CreateMethod · 0.65
FirstMethod · 0.45
WhereMethod · 0.45
QueryMethod · 0.45
SaveMethod · 0.45
SetDownloadsMethod · 0.45
SetSpeedMethod · 0.45
SetNameMethod · 0.45
SetFileIDMethod · 0.45

Tested by

no test coverage detected