Skip to content

Commit

Permalink
fix windows SyncDir issue
Browse files Browse the repository at this point in the history
Signed-off-by: D <d_kelsey@uk.ibm.com>
  • Loading branch information
D authored and ale-linux committed Oct 24, 2021
1 parent c90d50a commit b4c2731
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 16 deletions.
3 changes: 3 additions & 0 deletions ci/scripts/create_binary_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ make "release/${TARGET}"
mkdir "release/${TARGET}/config"
mv sampleconfig/*yaml "release/${TARGET}/config"
cd "release/${TARGET}"
if [ "$TARGET" == "windows-amd64" ]
for FILE in bin/*; do mv $FILE $FILE.exe; done
fi
tar -czvf "hyperledger-fabric-${TARGET}-${RELEASE}.tar.gz" bin config
16 changes: 0 additions & 16 deletions internal/fileutil/fileutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@ func CreateAndSyncFile(filePath string, content []byte, perm os.FileMode) error
return nil
}

// SyncDir fsyncs the given dir
func SyncDir(dirPath string) error {
dir, err := os.Open(dirPath)
if err != nil {
return errors.Wrapf(err, "error while opening dir:%s", dirPath)
}
if err := dir.Sync(); err != nil {
dir.Close()
return errors.Wrapf(err, "error while synching dir:%s", dirPath)
}
if err := dir.Close(); err != nil {
return errors.Wrapf(err, "error while closing dir:%s", dirPath)
}
return err
}

// SyncParentDir fsyncs the parent dir of the given path
func SyncParentDir(path string) error {
return SyncDir(filepath.Dir(path))
Expand Down
31 changes: 31 additions & 0 deletions internal/fileutil/syncdir.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// +build !windows

/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fileutil

import (
"os"

"github.com/pkg/errors"
)

// SyncDir fsyncs the given dir
func SyncDir(dirPath string) error {
dir, err := os.Open(dirPath)
if err != nil {
return errors.Wrapf(err, "error while opening dir:%s", dirPath)
}
if err := dir.Sync(); err != nil {
dir.Close()
return errors.Wrapf(err, "error while synching dir:%s", dirPath)
}
if err := dir.Close(); err != nil {
return errors.Wrapf(err, "error while closing dir:%s", dirPath)
}
return err
}
12 changes: 12 additions & 0 deletions internal/fileutil/syncdir_windows.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package fileutil

// SyncDir this is a noop on windows
func SyncDir(dirPath string) error {
return nil
}

0 comments on commit b4c2731

Please sign in to comment.