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

Function BuildFileResponse

service/explorer/response.go:407–434  ·  view source on GitHub ↗
(ctx context.Context, u *ent.User, f fs.File, hasher hashid.Encoder, cap *boolset.BooleanSet)

Source from the content-addressed store, hash-verified

405}
406
407func BuildFileResponse(ctx context.Context, u *ent.User, f fs.File, hasher hashid.Encoder, cap *boolset.BooleanSet) *FileResponse {
408 var owner *ent.User
409 if f != nil {
410 owner = f.Owner()
411 }
412
413 if cap == nil {
414 cap = f.Capabilities()
415 }
416
417 res := &FileResponse{
418 Type: int(f.Type()),
419 ID: hashid.EncodeFileID(hasher, f.ID()),
420 Name: f.DisplayName(),
421 CreatedAt: f.CreatedAt(),
422 UpdatedAt: f.UpdatedAt(),
423 Size: f.Size(),
424 Metadata: f.Metadata(),
425 Path: f.Uri(false).String(),
426 Shared: f.Shared(),
427 Capability: cap,
428 Owned: owner == nil || owner.ID == u.ID,
429 FolderSummary: f.FolderSummary(),
430 ExtendedInfo: BuildExtendedInfo(ctx, u, f, hasher),
431 PrimaryEntity: hashid.EncodeEntityID(hasher, f.PrimaryEntityID()),
432 }
433 return res
434}
435
436func BuildExtendedInfo(ctx context.Context, u *ent.User, f fs.File, hasher hashid.Encoder) *ExtendedInfo {
437 extendedInfo := f.ExtendedInfo()

Callers 7

ListMethod · 0.85
CreateMethod · 0.85
RenameMethod · 0.85
PutContentMethod · 0.85
GetMethod · 0.85
BuildListResponseFunction · 0.85

Calls 15

EncodeFileIDFunction · 0.92
EncodeEntityIDFunction · 0.92
BuildExtendedInfoFunction · 0.85
OwnerMethod · 0.65
CapabilitiesMethod · 0.65
TypeMethod · 0.65
IDMethod · 0.65
DisplayNameMethod · 0.65
CreatedAtMethod · 0.65
UpdatedAtMethod · 0.65
SizeMethod · 0.65
MetadataMethod · 0.65

Tested by

no test coverage detected