Skip to content

Commit

Permalink
Merge pull request #436 from Laevos/fix/indirectpinstatus
Browse files Browse the repository at this point in the history
fix #428: Use a regexp to match for indirect status in IPFSPinStatusF…
  • Loading branch information
hsanjuan committed May 27, 2018
2 parents 4155262 + a3c77da commit c4c6e17
Showing 1 changed file with 4 additions and 1 deletion.
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

0 comments on commit c4c6e17

Please sign in to comment.