Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #428: Use a regexp to match for indirect status in IPFSPinStatusF… #436

Merged
merged 2 commits into from
May 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package api

import (
"fmt"
"regexp"
"sort"
"strings"
"time"
Expand Down Expand Up @@ -103,10 +104,12 @@ type IPFSPinStatus int
// IPFSPinStatusFromString parses a string and returns the matching
// IPFSPinStatus.
func IPFSPinStatusFromString(t string) IPFSPinStatus {
// Since indirect statuses are of the form "indirect through <cid>", use a regexp to match
var ind, _ = regexp.MatchString("^indirect", t)
// TODO: This is only used in the http_connector to parse
// ipfs-daemon-returned values. Maybe it should be extended.
switch {
case t == "indirect":
case ind:
return IPFSPinStatusIndirect
case t == "direct":
return IPFSPinStatusDirect
Expand Down