MCPcopy Index your code
hub / github.com/aptly-dev/aptly / apiDiskFree

Function apiDiskFree

api/storage.go:28–45  ·  view source on GitHub ↗

@Summary Get Storage Utilization @Description **Get disk free information of aptly storage** @Description @Description Units in MiB. @Tags Status @Produce json @Success 200 {object} diskFree "Storage information" @Failure 400 {object} Error "Internal Error" @Router /api/storage [get]

(c *gin.Context)

Source from the content-addressed store, hash-verified

26// @Failure 400 {object} Error "Internal Error"
27// @Router /api/storage [get]
28func apiDiskFree(c *gin.Context) {
29 var df diskFree
30
31 fs := context.Config().GetRootDir()
32
33 var stat syscall.Statfs_t
34 err := syscall.Statfs(fs, &stat)
35 if err != nil {
36 AbortWithJSONError(c, 400, fmt.Errorf("Error getting storage info on %s: %s", fs, err))
37 return
38 }
39
40 df.Total = uint64(stat.Blocks) * uint64(stat.Bsize) / 1048576
41 df.Free = uint64(stat.Bavail) * uint64(stat.Bsize) / 1048576
42 df.PercentFull = 100.0 - float32(stat.Bavail)/float32(stat.Blocks)*100.0
43
44 c.JSON(200, df)
45}

Callers

nothing calls this directly

Calls 3

AbortWithJSONErrorFunction · 0.85
GetRootDirMethod · 0.80
ConfigMethod · 0.80

Tested by

no test coverage detected