+21
-2
knotserver/xrpc/repo_blob.go
+21
-2
knotserver/xrpc/repo_blob.go
···
42
return
43
}
44
45
contents, err := gr.RawContent(treePath)
46
if err != nil {
47
x.Logger.Error("file content", "error", err.Error(), "treePath", treePath)
···
101
var encoding string
102
103
isBinary := !isTextual(mimeType)
104
105
if isBinary {
106
content = base64.StdEncoding.EncodeToString(contents)
···
113
response := tangled.RepoBlob_Output{
114
Ref: ref,
115
Path: treePath,
116
-
Content: content,
117
Encoding: &encoding,
118
-
Size: &[]int64{int64(len(contents))}[0],
119
IsBinary: &isBinary,
120
}
121
···
42
return
43
}
44
45
+
// first check if this path is a submodule
46
+
submodule, err := gr.Submodule(treePath)
47
+
if err != nil {
48
+
// this is okay, continue and try to treat it as a regular file
49
+
} else {
50
+
response := tangled.RepoBlob_Output{
51
+
Ref: ref,
52
+
Path: treePath,
53
+
Submodule: &tangled.RepoBlob_Submodule{
54
+
Name: submodule.Name,
55
+
Url: submodule.URL,
56
+
Branch: &submodule.Branch,
57
+
},
58
+
}
59
+
writeJson(w, response)
60
+
return
61
+
}
62
+
63
contents, err := gr.RawContent(treePath)
64
if err != nil {
65
x.Logger.Error("file content", "error", err.Error(), "treePath", treePath)
···
119
var encoding string
120
121
isBinary := !isTextual(mimeType)
122
+
size := int64(len(contents))
123
124
if isBinary {
125
content = base64.StdEncoding.EncodeToString(contents)
···
132
response := tangled.RepoBlob_Output{
133
Ref: ref,
134
Path: treePath,
135
+
Content: &content,
136
Encoding: &encoding,
137
+
Size: &size,
138
IsBinary: &isBinary,
139
}
140