Skip to content

Commit

Permalink
fix: fix sock file creation
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Dec 1, 2019
1 parent 8499ea7 commit 6a83055
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
23 changes: 15 additions & 8 deletions go/bind/ipfs/bind_sockmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ import (

// Filename is base 36 encoded to avoid conflict on case-insensitive filesystems
var maxSockFilename = strconv.FormatUint(math.MaxUint32, 36)
var paddingFormatStr = "u%0" + strconv.Itoa(len(maxSockFilename)) + "s"
var paddingFormatStr = "%0" + strconv.Itoa(len(maxSockFilename)) + "s"

// make it short
const UDSDir = "u"
const UDSDir = "sock"

type SockManager struct {
sockDirPath string
Expand All @@ -38,18 +37,26 @@ func NewSockManager(path string) (*SockManager, error) {
return nil, errors.Wrap(err, "sock parent folder doesn't exist")
}

// sockDirPath := filepath.Join(abspath, UDSDir)
sockDirPath := path
sockDirPath := filepath.Join(abspath, UDSDir)

// max length for a unix domain socket path is around 103 char (108 - '/unix')
maxSockPath := filepath.Join("/unix", sockDirPath, maxSockFilename)
if len(maxSockPath) > syscall.SizeofSockaddrAny {
return nil, errors.New("path length exceeded")
}

// if err := os.MkdirAll(sockDirPath, 6755); err != nil {
// return nil, errors.Wrap(err, "can't create sock folder")
// }
// remove sock folder from previous app run if exists
_, err = os.Stat(sockDirPath)
if !os.IsNotExist(err) {
err := os.RemoveAll(sockDirPath)
if err != nil {
return nil, errors.Wrap(err, "can't cleanup old sock folder")
}
}

if err := os.MkdirAll(sockDirPath, 0700); err != nil {
return nil, errors.Wrap(err, "can't create sock folder")
}

return &SockManager{
sockDirPath: sockDirPath,
Expand Down
4 changes: 2 additions & 2 deletions ios/Example/GomobileIPFS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -486,7 +486,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 9.3;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand Down
2 changes: 1 addition & 1 deletion ios/Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ EXTERNAL SOURCES:

SPEC CHECKSUMS:
FBSnapshotTestCase: 094f9f314decbabe373b87cc339bea235a63e07a
GomobileIPFS: a47da7da8436fe74401bef2944cd404edb6dadcc
GomobileIPFS: 1d0fa985b6310d12756699664f59ed038db1f1d4

PODFILE CHECKSUM: b45f1652965217a3a80a8b94b9989999f6727e6c

Expand Down

0 comments on commit 6a83055

Please sign in to comment.