Compute sizes from children files - Does not handle lock, should be used by other functions handling lock
(ctx context.Context, node tree.ITreeNode)
| 214 | // Compute sizes from children files - Does not handle lock, should be |
| 215 | // used by other functions handling lock |
| 216 | func (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 | } |
no test coverage detected