(ctx context.Context, file int, name string, speed int, reuse bool)
| 378 | } |
| 379 | |
| 380 | func (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 | |
| 400 | func (f *fileClient) GetByHashID(ctx context.Context, hashID string) (*ent.File, error) { |
| 401 | id, err := f.hasher.Decode(hashID, hashid.FileID) |
nothing calls this directly
no test coverage detected