From affe3c2c1295d86a8ab35be61b95a6bb670ce86d Mon Sep 17 00:00:00 2001 From: chrislu Date: Fri, 4 Feb 2022 21:32:27 -0800 Subject: [PATCH] change to util.WriteFile --- weed/command/scaffold.go | 4 ++-- weed/images/orientation_test.go | 3 ++- weed/images/resizing_test.go | 2 +- weed/replication/sub/notification_kafka.go | 2 +- weed/server/volume_grpc_copy.go | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/weed/command/scaffold.go b/weed/command/scaffold.go index 6fcbd7efb..fb81f9966 100644 --- a/weed/command/scaffold.go +++ b/weed/command/scaffold.go @@ -2,7 +2,7 @@ package command import ( "fmt" - "os" + "github.com/chrislusf/seaweedfs/weed/util" "path/filepath" "github.com/chrislusf/seaweedfs/weed/command/scaffold" @@ -56,7 +56,7 @@ func runScaffold(cmd *Command, args []string) bool { } if *outputPath != "" { - os.WriteFile(filepath.Join(*outputPath, *config+".toml"), []byte(content), 0644) + util.WriteFile(filepath.Join(*outputPath, *config+".toml"), []byte(content), 0644) } else { fmt.Println(content) } diff --git a/weed/images/orientation_test.go b/weed/images/orientation_test.go index e9743bc0c..92bf4fb8f 100644 --- a/weed/images/orientation_test.go +++ b/weed/images/orientation_test.go @@ -1,6 +1,7 @@ package images import ( + "github.com/chrislusf/seaweedfs/weed/util" "os" "testing" ) @@ -12,7 +13,7 @@ func TestXYZ(t *testing.T) { fixed_data := FixJpgOrientation(dat) - os.WriteFile("fixed1.jpg", fixed_data, 0644) + util.WriteFile("fixed1.jpg", fixed_data, 0644) os.Remove("fixed1.jpg") diff --git a/weed/images/resizing_test.go b/weed/images/resizing_test.go index 33b904445..63a6bb3b2 100644 --- a/weed/images/resizing_test.go +++ b/weed/images/resizing_test.go @@ -15,7 +15,7 @@ func TestResizing(t *testing.T) { buf := new(bytes.Buffer) buf.ReadFrom(resized) - os.WriteFile("resized1.png", buf.Bytes(), 0644) + util.WriteFile("resized1.png", buf.Bytes(), 0644) os.Remove("resized1.png") diff --git a/weed/replication/sub/notification_kafka.go b/weed/replication/sub/notification_kafka.go index 41a4caaf3..11bd2ffb4 100644 --- a/weed/replication/sub/notification_kafka.go +++ b/weed/replication/sub/notification_kafka.go @@ -137,7 +137,7 @@ func (progress *KafkaProgress) saveProgress() error { if err != nil { return fmt.Errorf("failed to marshal progress: %v", err) } - err = os.WriteFile(progress.offsetFile, data, 0640) + err = util.WriteFile(progress.offsetFile, data, 0640) if err != nil { return fmt.Errorf("failed to save progress to %s: %v", progress.offsetFile, err) } diff --git a/weed/server/volume_grpc_copy.go b/weed/server/volume_grpc_copy.go index 52181a771..6ed2724f1 100644 --- a/weed/server/volume_grpc_copy.go +++ b/weed/server/volume_grpc_copy.go @@ -67,7 +67,7 @@ func (vs *VolumeServer) VolumeCopy(req *volume_server_pb.VolumeCopyRequest, stre dataBaseFileName = storage.VolumeFileName(location.Directory, volFileInfoResp.Collection, int(req.VolumeId)) indexBaseFileName = storage.VolumeFileName(location.IdxDirectory, volFileInfoResp.Collection, int(req.VolumeId)) - os.WriteFile(dataBaseFileName+".note", []byte(fmt.Sprintf("copying from %s", req.SourceDataNode)), 0755) + util.WriteFile(dataBaseFileName+".note", []byte(fmt.Sprintf("copying from %s", req.SourceDataNode)), 0755) defer func() { if err != nil {