|
|
|
tinygit/storage_inventory.go raw
| 1 | package tinygit | | 2 | | | 3 | import ( | | 4 | "context" | | 5 | "errors" | | 6 | "io/fs" | | 7 | "path/filepath" | | 8 | ) | | 9 | | | 10 | // StorageInventory reports retained bytes for one accepted repository. It is | | 11 | // deliberately derived from the local object store so the self-hosted result | | 12 | // has no hosted fuel or quota fields. | | 13 | func (g *GitRelay) StorageInventory(ctx context.Context, owner, identifier string) (map[string]any, error) { | | 14 | if err := ctx.Err(); err != nil { | | 15 | return nil, err | | 16 | } | | 17 | repo, err := g.lookup(owner, identifier) | | 18 | if err != nil { | | 19 | return nil, errors.New("not found: repository" ) | | 20 | } | | 21 | var files, bytes int64 | | 22 | err = filepath.WalkDir(g.repoPath(repo), func(_ string, entry fs.DirEntry, walkErr error) error { | | 23 | if walkErr != nil { | | 24 | return walkErr | | 25 | } | | 26 | if entry.IsDir() { | | 27 | return nil | | 28 | } | | 29 | info, err := entry.Info() | | 30 | if err != nil { | | 31 | return err | | 32 | } | | 33 | files++ | | 34 | bytes += info.Size() | | 35 | return nil | | 36 | }) | | 37 | if err != nil { | | 38 | return nil, err | | 39 | } | | 40 | return map[string]any{ | | 41 | "repository" : map[string]any{"owner" : owner, "identifier" : identifier, "announcement" : repo.EventID}, | | 42 | "backend" : "filesystem" , | | 43 | "objects" : map[string]any{"count" : files, "rawBytes" : bytes, "compressedBytes" : bytes, "metadataBytes" : int64(0)}, | | 44 | "refs" : len(repo.Refs), | | 45 | "receipts" : 0, | | 46 | }, nil | | 47 | } |
|
|
About| owner | c01503e8035f |
|---|
| visibility | public |
|---|
| head | d730679639bf |
|---|
Maintainers- c01503e8035f owner
- ba1b5beed5b5 agent hermes
Clonehttps://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git
|