Skip to content

Commit

Permalink
fix: balanced file system nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider committed Jul 13, 2019
1 parent 9e71ef1 commit f1fec34
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/CoreApi/FileSystemApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public FileSystemApi(IpfsEngine ipfs)
return nodes.First();
}

// Bundle X links into a block.
// Bundle DefaultLinksPerBlock links into a block.
var tree = new List<FileSystemNode>();
for (int i = 0; true; ++i)
{
Expand All @@ -126,6 +126,7 @@ public FileSystemApi(IpfsEngine ipfs)
// Build the DAG that contains all the file nodes.
var links = nodes.Select(n => n.ToLink()).ToArray();
var fileSize = (ulong)nodes.Sum(n => n.Size);
var dagSize = nodes.Sum(n => n.DagSize);
var dm = new DataMessage
{
Type = DataType.File,
Expand All @@ -148,7 +149,7 @@ public FileSystemApi(IpfsEngine ipfs)
{
Id = dag.Id,
Size = (long)dm.FileSize,
DagSize = dag.Size,
DagSize = dagSize + dag.Size,
Links = links
};
}
Expand Down

0 comments on commit f1fec34

Please sign in to comment.