Skip to content

Commit f41c61c

Browse files
author
Ömral Cörüt
committed
Fix Cat Method Bug
1 parent 7275857 commit f41c61c

File tree

3 files changed

+91
-4
lines changed

3 files changed

+91
-4
lines changed

ipfs-api-kotlin.iml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module external.linked.project.id="ipfs-api-kotlin" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="com.github.ligi" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
3+
<component name="FacetManager">
4+
<facet type="android-gradle" name="Android-Gradle">
5+
<configuration>
6+
<option name="GRADLE_PROJECT_PATH" value=":" />
7+
</configuration>
8+
</facet>
9+
<facet type="java-gradle" name="Java-Gradle">
10+
<configuration>
11+
<option name="BUILD_FOLDER_PATH" value="$MODULE_DIR$/build" />
12+
<option name="BUILDABLE" value="true" />
13+
</configuration>
14+
</facet>
15+
<facet type="kotlin-language" name="Kotlin">
16+
<configuration version="3" platform="JVM 1.6" useProjectSettings="false">
17+
<compilerSettings />
18+
<compilerArguments>
19+
<option name="destination" value="$MODULE_DIR$/build/classes/kotlin/main" />
20+
<option name="classpath" value="$USER_HOME$/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib/1.2.70/b5b9449f73ce7bf312e89a7560cb3c209a0fa13e/kotlin-stdlib-1.2.70.jar:/Users/omralcorut/.gradle/caches/modules-2/files-2.1/com.squareup.moshi/moshi/1.4.0/d67ad038adfd55dc276488a54f4944dfae5ff8ec/moshi-1.4.0.jar:/Users/omralcorut/.gradle/caches/modules-2/files-2.1/com.squareup.okhttp3/okhttp/3.11.0/75966e05a49046ca2ae734e5626f28837a8d1e82/okhttp-3.11.0.jar:/Users/omralcorut/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-stdlib-common/1.2.70/6ea722d7d0b9451293e739076ddb6a4108d57b6b/kotlin-stdlib-common-1.2.70.jar:/Users/omralcorut/.gradle/caches/modules-2/files-2.1/org.jetbrains/annotations/13.0/919f0dfe192fb4e063e7dacadee7f8bb9a2672a9/annotations-13.0.jar:/Users/omralcorut/.gradle/caches/modules-2/files-2.1/com.squareup.okio/okio/1.14.0/102d7be47241d781ef95f1581d414b0943053130/okio-1.14.0.jar" />
21+
<option name="noStdlib" value="true" />
22+
<option name="noReflect" value="true" />
23+
<option name="moduleName" value="ipfs-api-kotlin" />
24+
<option name="addCompilerBuiltIns" value="true" />
25+
<option name="loadBuiltInsFromDependencies" value="true" />
26+
<option name="languageVersion" value="1.2" />
27+
<option name="apiVersion" value="1.2" />
28+
<option name="pluginOptions">
29+
<array />
30+
</option>
31+
<option name="pluginClasspaths">
32+
<array />
33+
</option>
34+
<option name="coroutinesState" value="warn" />
35+
<option name="errors">
36+
<ArgumentParseErrors />
37+
</option>
38+
</compilerArguments>
39+
</configuration>
40+
</facet>
41+
</component>
42+
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
43+
<output url="file://$MODULE_DIR$/build/classes/java/main" />
44+
<output-test url="file://$MODULE_DIR$/build/classes/java/test" />
45+
<exclude-output />
46+
<content url="file://$MODULE_DIR$">
47+
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
48+
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
49+
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
50+
<sourceFolder url="file://$MODULE_DIR$/src/test/kotlin" isTestSource="true" />
51+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
52+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
53+
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
54+
<excludeFolder url="file://$MODULE_DIR$/build" />
55+
</content>
56+
<orderEntry type="inheritedJdk" />
57+
<orderEntry type="sourceFolder" forTests="false" />
58+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib:1.2.70" level="project" />
59+
<orderEntry type="library" name="Gradle: com.squareup.moshi:moshi:1.4.0" level="project" />
60+
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.11.0" level="project" />
61+
<orderEntry type="library" name="Gradle: org.jetbrains.kotlin:kotlin-stdlib-common:1.2.70" level="project" />
62+
<orderEntry type="library" name="Gradle: org.jetbrains:annotations:13.0" level="project" />
63+
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.14.0" level="project" />
64+
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup.okhttp3:mockwebserver:3.11.0" level="project" />
65+
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12" level="project" />
66+
<orderEntry type="library" scope="TEST" name="Gradle: org.mockito:mockito-core:2.12.0" level="project" />
67+
<orderEntry type="library" scope="TEST" name="Gradle: org.assertj:assertj-core:3.10.0" level="project" />
68+
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3" level="project" />
69+
<orderEntry type="library" scope="TEST" name="Gradle: net.bytebuddy:byte-buddy:1.7.9" level="project" />
70+
<orderEntry type="library" scope="TEST" name="Gradle: net.bytebuddy:byte-buddy-agent:1.7.9" level="project" />
71+
<orderEntry type="library" scope="TEST" name="Gradle: org.objenesis:objenesis:2.6" level="project" />
72+
<orderEntry type="library" exported="" name="Gradle: kotlin-stdlib-1.2.70" level="project" />
73+
<orderEntry type="library" exported="" name="Gradle: moshi-1.4.0" level="project" />
74+
<orderEntry type="library" exported="" name="Gradle: okhttp-3.11.0" level="project" />
75+
<orderEntry type="library" exported="" name="Gradle: kotlin-stdlib-common-1.2.70" level="project" />
76+
<orderEntry type="library" exported="" name="Gradle: annotations-13.0" level="project" />
77+
<orderEntry type="library" exported="" name="Gradle: okio-1.14.0" level="project" />
78+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: mockwebserver-3.11.0" level="project" />
79+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: junit-4.12" level="project" />
80+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: mockito-core-2.12.0" level="project" />
81+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: assertj-core-3.10.0" level="project" />
82+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: hamcrest-core-1.3" level="project" />
83+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: byte-buddy-1.7.9" level="project" />
84+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: byte-buddy-agent-1.7.9" level="project" />
85+
<orderEntry type="library" exported="" scope="TEST" name="Gradle: objenesis-2.6" level="project" />
86+
</component>
87+
</module>

src/main/kotlin/io/ipfs/kotlin/commands/Get.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ class Get(val ipfs: IPFSConnection) {
1111
*
1212
* @param hash The hash of the content in base58.
1313
*/
14-
fun cat(hash: String): String = ipfs.callCmd("cat/$hash").use(ResponseBody::string)
14+
fun cat(hash: String): String = ipfs.callCmd("cat?arg=$hash").use(ResponseBody::string)
1515

1616
/**
1717
* Cat IPFS content and return it as ByteArray.
1818
*
1919
* @param hash The hash of the content in base58.
2020
*/
21-
fun catBytes(hash: String): ByteArray = ipfs.callCmd("cat/$hash").use(ResponseBody::bytes)
21+
fun catBytes(hash: String): ByteArray = ipfs.callCmd("cat?arg=$hash").use(ResponseBody::bytes)
2222

2323
/**
2424
* Cat IPFS content and process it using InputStream.
@@ -27,7 +27,7 @@ class Get(val ipfs: IPFSConnection) {
2727
* @param handler Callback which handle processing the input stream. When the callback return the stream and the request body will be closed.
2828
*/
2929
fun catStream(hash: String, handler: (stream: InputStream) -> Unit): Unit =
30-
ipfs.callCmd("cat/$hash").use { body ->
30+
ipfs.callCmd("cat?arg=$hash").use { body ->
3131
val inputStream = body.byteStream()
3232
inputStream.use(handler)
3333
}

src/test/kotlin/io/ipfs/kotlin/TestGet.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class TestGet : BaseIPFSWebserverTest() {
1818
assertThat(result).isEqualTo("result")
1919

2020
val executedRequest = server.takeRequest()
21-
assertThat(executedRequest.path).startsWith("/cat/hash")
21+
assertThat(executedRequest.path).startsWith("/cat?arg=hash")
2222

2323
}
2424

0 commit comments

Comments
 (0)