Skip to content

Commit ba39df8

Browse files
committed
Release 0.7.0. See release notes or expand full commit message for details.
[Breaking] Fixed WebRTC-Direct support added in Kubo 0.30.0. Removed the Object API completely, since Kubo replaced it with the DAG API and no longer offers it. Refactored the FileSystem API to: - Enable proper directory uploads via a new `AddAsync` method that takes File and Folder parts separately. - Bring `FileAddOptions` fully up-to-date with modern Kubo. - Remove `AddDirectoryAsync` (used missing Object API). Updated several types to use one of int, long or ulong for Size matching the Kubo API. [New] Added IFilestoreApi and the corresponding types. Added a new type `DagCid` that can be used to automatically create IPLD link references when serialized. Added the IBlockStat type, analogous to the BlockStat struct in Kubo.
1 parent 3977409 commit ba39df8

30 files changed

+613
-477
lines changed

src/CoreApi/AddFileOptions.cs

Lines changed: 64 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,44 +13,41 @@ public class AddFileOptions
1313
/// </summary>
1414
/// <value>
1515
/// If <b>true</b> the data is pinned to local storage and will not be
16-
/// garbage collected. The default is <b>true</b>.
16+
/// garbage collected. Required: no. The default is <b>true</b>.
1717
/// </value>
18-
public bool Pin { get; set; } = true;
18+
public bool? Pin { get; set; }
1919

2020
/// <summary>
21-
/// The maximum number of data bytes in a block.
21+
/// Chunking algorithm, size-[bytes], rabin-[min]-[avg]-[max] or buzhash. Required: no.
2222
/// </summary>
2323
/// <value>
24-
/// The default is 256 * 1024 (‭262,144) bytes.‬
24+
/// Required: no. The default is 256 * 1024 (size-‭262144) bytes.‬
2525
/// </value>
26-
public int ChunkSize { get; set; } = 256 * 1024;
26+
public string? Chunker { get; set; }
2727

2828
/// <summary>
2929
/// Determines if the trickle-dag format is used for dag generation.
3030
/// </summary>
3131
/// <value>
32-
/// The default is <b>false</b>.
32+
/// Required: no. The default is <b>false</b>.
3333
/// </value>
34-
public bool Trickle { get; set; } = false;
34+
public bool? Trickle { get; set; }
3535

3636
/// <summary>
3737
/// Determines if added file(s) are wrapped in a directory object.
3838
/// </summary>
3939
/// <value>
40-
/// The default is <b>false</b>.
40+
/// Required: no. The default is <b>false</b>.
4141
/// </value>
42-
public bool Wrap { get; set; } = false;
42+
public bool? Wrap { get; set; }
4343

4444
/// <summary>
45-
/// Determines if raw blocks are used for leaf data blocks.
45+
/// Determines if raw blocks are used for leaf nodes.
4646
/// </summary>
4747
/// <value>
48-
/// The default is <b>false</b>.
48+
/// Required: no. The default is <b>false</b>.
4949
/// </value>
50-
/// <remarks>
51-
/// <b>RawLeaves</b> and <see cref="ProtectionKey"/> are mutually exclusive.
52-
/// </remarks>
53-
public bool RawLeaves { get; set; } = false;
50+
public bool? RawLeaves { get; set; }
5451

5552
/// <summary>
5653
/// The hashing algorithm name to use.
@@ -60,51 +57,76 @@ public class AddFileOptions
6057
/// Defaults to <see cref="MultiHash.DefaultAlgorithmName"/>.
6158
/// </value>
6259
/// <seealso cref="MultiHash"/>
63-
public string Hash { get; set; } = MultiHash.DefaultAlgorithmName;
60+
public string? Hash { get; set; }
6461

6562
/// <summary>
66-
/// The encoding algorithm name to use.
63+
/// Determines if only file information is produced.
6764
/// </summary>
6865
/// <value>
69-
/// The <see cref="MultiBase"/> algorithm name used to produce the <see cref="Cid"/>.
70-
/// Defaults to <see cref="MultiBase.DefaultAlgorithmName"/>.
66+
/// If <b>true</b> no data is added to IPFS. Required: no. The default is <b>false</b>.
7167
/// </value>
72-
/// <seealso cref="MultiBase"/>
73-
public string Encoding { get; set; } = MultiBase.DefaultAlgorithmName;
68+
public bool? OnlyHash { get; set; }
7469

7570
/// <summary>
76-
/// Determines if only file information is produced.
71+
/// Used to report the progress of a file transfer.
7772
/// </summary>
78-
/// <value>
79-
/// If <b>true</b> no data is added to IPFS. The default is <b>false</b>.
80-
/// </value>
81-
public bool OnlyHash { get; set; } = false;
73+
public IProgress<TransferProgress>? Progress { get; set; }
8274

8375
/// <summary>
84-
/// The key name used to protect (encrypt) the file contents.
76+
/// Add the file using filestore. Implies raw-leaves.
8577
/// </summary>
86-
/// <value>
87-
/// The name of an existing key.
88-
/// </value>
89-
/// <remarks>
90-
/// <b>ProtectionKey</b> and <see cref="RawLeaves"/> are mutually exclusive.
91-
/// </remarks>
92-
/// <seealso cref="IKeyApi"/>
93-
public string? ProtectionKey { get; set; }
78+
public bool? NoCopy { get; set; }
9479

9580
/// <summary>
96-
/// Used to report the progress of a file transfer.
81+
/// Check the filestore for pre-existing blocks.
9782
/// </summary>
98-
public IProgress<TransferProgress>? Progress { get; set; }
83+
public bool? FsCache { get; set; }
9984

10085
/// <summary>
101-
/// Add the file using filestore. Implies raw-leaves.
86+
/// Defaults to 0 unless an option that depends on CIDv1 is passed.
87+
/// Passing version 1 will cause the raw-leaves option to default to true.
88+
/// Required: no.
10289
/// </summary>
103-
public bool? NoCopy {get; set; }
90+
public int? CidVersion { get; set; }
10491

105-
/// <summary>
106-
/// Check the filestore for pre-existing blocks.
92+
/// <summary>
93+
/// Inline small blocks into CIDs. (experimental). Required: no.
94+
/// </summary>
95+
public bool? Inline { get; set; }
96+
97+
/// <summary>
98+
/// Maximum block size to inline. (experimental). Default: 32. Required: no.
99+
/// </summary>
100+
public int? InlineLimit { get; set; }
101+
102+
/// <summary>
103+
/// Add reference to Files API (MFS) at the provided path. Required: no.
104+
/// </summary>
105+
public string? ToFiles { get; set; }
106+
107+
/// <summary>
108+
/// Apply existing POSIX permissions to created UnixFS entries. Disables raw-leaves. (experimental). Required: no.
109+
/// </summary>
110+
public bool? PreserveMode { get; set; }
111+
112+
/// <summary>
113+
/// Apply existing POSIX modification time to created UnixFS entries. Disables raw-leaves. (experimental). Required: no.
114+
/// </summary>
115+
public bool? PreserveMtime { get; set; }
116+
117+
/// <summary>
118+
/// Custom POSIX file mode to store in created UnixFS entries. Disables raw-leaves. (experimental). Required: no.
119+
/// </summary>
120+
public uint? Mode { get; set; }
121+
122+
/// <summary>
123+
/// Custom POSIX modification time to store in created UnixFS entries (seconds before or after the Unix Epoch). Disables raw-leaves. (experimental). Required: no.
124+
/// </summary>
125+
public long? Mtime { get; set; }
126+
127+
/// <summary>
128+
/// Custom POSIX modification time (optional time fraction in nanoseconds).
107129
/// </summary>
108-
public bool? FsCache{get; set; }
130+
public uint? MtimeNsecs { get; set; }
109131
}
110132
}

src/CoreApi/CarImportOutput.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Ipfs.CoreApi
4+
{
5+
/// <summary>
6+
/// CarImportOutput is the output type of the 'dag import' commands
7+
/// </summary>
8+
/// <remarks>See also <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L63"/></remarks>
9+
public class CarImportOutput
10+
{
11+
/// <summary>
12+
/// Root is the metadata for a root pinning response
13+
/// </summary>
14+
[JsonProperty("Root", NullValueHandling = NullValueHandling.Ignore)]
15+
public RootMeta? Root { get; set; }
16+
17+
/// <summary>
18+
/// Stats contains statistics about the imported CAR file, if requested.
19+
/// </summary>
20+
[JsonProperty("Stats", NullValueHandling = NullValueHandling.Ignore)]
21+
public CarImportStats? Stats { get; set; }
22+
23+
/// <summary>
24+
/// RootMeta is the metadata for a root pinning response
25+
/// </summary>
26+
public record RootMeta
27+
{
28+
/// <summary>
29+
/// The CID of the root of the imported DAG.
30+
/// </summary>
31+
public required DagCid Cid { get; set; }
32+
33+
/// <summary>
34+
/// The error message if pinning failed
35+
/// </summary>
36+
public string? PinErrorMsg { get; set; }
37+
}
38+
39+
/// <summary>
40+
/// Statistics about an imported CAR file.
41+
/// </summary>
42+
public record CarImportStats
43+
{
44+
/// <summary>
45+
/// The number of blocks in the CAR file.
46+
/// </summary>
47+
[JsonProperty("BlockCount")]
48+
public ulong BlockCount { get; set; }
49+
50+
/// <summary>
51+
/// The number of block bytes in the CAR file.
52+
/// </summary>
53+
[JsonProperty("BlockBytesCount")]
54+
public ulong BlockBytesCount { get; set; }
55+
}
56+
}
57+
58+
59+
}

src/CoreApi/DagResolveOutput.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Ipfs.CoreApi
2+
{
3+
/// <summary>
4+
/// The result of a DAG resolve operation.
5+
/// </summary>
6+
/// <param name="Id">The cid of the resolved dag path.</param>
7+
/// <param name="RemPath">Unknown usage. See <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L54"/></param>
8+
public record DagResolveOutput(DagCid Id, string RemPath);
9+
}

src/CoreApi/DagStat.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Ipfs.CoreApi
4+
{
5+
/// <summary>
6+
/// Statistics about a DAG block.
7+
/// </summary>
8+
public record DagStat
9+
{
10+
/// <summary>
11+
/// The CID of the block.
12+
/// </summary>
13+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
14+
public DagCid? Cid { get; set; }
15+
16+
/// <summary>
17+
/// The size of the block.
18+
/// </summary>
19+
public ulong? Size { get; set; }
20+
21+
/// <summary>
22+
/// The number of links in the block.
23+
/// </summary>
24+
public long NumBlocks { get; set; }
25+
}
26+
27+
}

src/CoreApi/DagStatSummary.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
4+
namespace Ipfs.CoreApi
5+
{
6+
/// <summary>
7+
/// The output of a DAG stat operation.
8+
/// </summary>
9+
/// <remarks>
10+
/// Adapted from <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L326"/>
11+
/// </remarks>
12+
public record DagStatSummary
13+
{
14+
/// <summary>
15+
/// The size of redundant nodes in this Dag tree.
16+
/// </summary>
17+
/// <remarks>
18+
/// Docs sourced from <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/stat.go#L60-L70"/>
19+
/// </remarks>
20+
[JsonIgnore]
21+
public ulong RedundantSize { get; set; }
22+
23+
/// <summary>
24+
/// The number of unique CIDs in this Dag tree.
25+
/// </summary>
26+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
27+
public int? UniqueBlocks { get; set; }
28+
29+
/// <summary>
30+
/// The total size of all unique dag blocks in this tree.
31+
/// </summary>
32+
/// <remarks>
33+
/// Docs sourced from <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/stat.go#L58"/>
34+
/// </remarks>
35+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
36+
public ulong? TotalSize { get; set; }
37+
38+
/// <summary>
39+
/// The difference between <see cref="RedundantSize"/> and <see cref="TotalSize"/>.
40+
/// </summary>
41+
/// <remarks>
42+
/// Docs sourced from code <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L351" />
43+
/// </remarks>
44+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
45+
public ulong? SharedSize { get; set; }
46+
47+
/// <summary>
48+
/// The ratio of <see cref="RedundantSize"/> to <see cref="TotalSize"/>.
49+
/// </summary>
50+
/// <remarks>
51+
/// Docs sourced from code <see href="https://github.com/ipfs/kubo/blob/f5b855550ca73acf5dd3a2001e2a7192cab7c249/core/commands/dag/dag.go#L351" />
52+
/// </remarks>
53+
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
54+
public float? Ratio { get; set; }
55+
56+
/// <summary>
57+
/// If requested, the stats for each DAG in the tree.
58+
/// </summary>
59+
[JsonProperty("DagStats", NullValueHandling = NullValueHandling.Ignore)]
60+
public IEnumerable<DagStat>? DagStatsArray { get; set; }
61+
}
62+
63+
}

src/CoreApi/FilePart.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System.IO;
2+
3+
namespace Ipfs.CoreApi
4+
{
5+
/// <summary>
6+
/// Represents a file to be added to IPFS.
7+
/// </summary>
8+
public class FilePart
9+
{
10+
/// <summary>
11+
/// The name of the file or the relative path to the file in a folder.
12+
/// </summary>
13+
public required string Name { get; set; }
14+
15+
/// <summary>
16+
/// A stream containing the file's data.
17+
/// </summary>
18+
public required Stream? Data { get; set; }
19+
20+
/// <summary>
21+
/// Can be set to the location of the file in the filesystem (within the IPFS root), or to its full web URL.
22+
/// </summary>
23+
/// <remarks>
24+
/// Included for filestore/urlstore features that are enabled with the nocopy option
25+
/// </remarks>
26+
public string? AbsolutePath { get; set; }
27+
}
28+
}

src/CoreApi/FilestoreDuplicate.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
namespace Ipfs.CoreApi
2+
{
3+
/// <summary>
4+
/// The response object for the <see cref="IFilestoreApi.DupsAsync"/> method.
5+
/// </summary>
6+
public record FilestoreDuplicate
7+
{
8+
/// <summary>
9+
/// Any error in the <see cref="IFilestoreApi"/> Dups response.
10+
/// </summary>
11+
public required string Err { get; set; }
12+
13+
/// <summary>
14+
/// The cid in the <see cref="IFilestoreApi"/> Dups response.
15+
/// </summary>
16+
public required Cid Ref { get; set; }
17+
}
18+
}

0 commit comments

Comments
 (0)