MCPcopy Create free account
hub / github.com/pydio/cells / folderSize

Method folderSize

common/storage/sql/index/folder-size-cache.go:216–242  ·  view source on GitHub ↗

Compute sizes from children files - Does not handle lock, should be used by other functions handling lock

(ctx context.Context, node tree.ITreeNode)

Source from the content-addressed store, hash-verified

214// Compute sizes from children files - Does not handle lock, should be
215// used by other functions handling lock
216func (dao *FolderSizeCacheSQL) folderSize(ctx context.Context, node tree.ITreeNode) error {
217 mpath := node.GetMPath().ToString()
218 ca, err := cache_helper.ResolveCache(ctx, common.CacheTypeShared, folderSizeCacheConfig)
219 if err != nil {
220 return err
221 }
222
223 if data, ok := ca.GetBytes(mpath); ok && data != nil {
224 if sizeInt, err := strconv.ParseInt(string(data), 10, 64); err == nil && sizeInt > 0 {
225 node.GetNode().SetSize(sizeInt)
226 }
227 }
228
229 size, err := dao.GetNodeChildrenSize(ctx, node.GetMPath())
230 if err != nil {
231 return err
232 }
233
234 node.GetNode().SetSize(int64(size))
235
236 // using a string representation for byte size since redis does not support int64.
237 if err = ca.Set(mpath, []byte(strconv.FormatInt(int64(size), 10))); err != nil {
238 return err
239 }
240
241 return nil
242}

Callers 5

GetNodeByMPathMethod · 0.95
GetNodeByPathMethod · 0.95
GetNodeByUUIDMethod · 0.95
GetNodeChildrenMethod · 0.95
GetNodeTreeMethod · 0.95

Calls 7

ToStringMethod · 0.80
GetMPathMethod · 0.65
GetBytesMethod · 0.65
SetSizeMethod · 0.65
GetNodeMethod · 0.65
GetNodeChildrenSizeMethod · 0.65
SetMethod · 0.65

Tested by

no test coverage detected