From 81f29cdef506a58bdcb41f2221c6a8abca03455c Mon Sep 17 00:00:00 2001 From: "lilong.129" Date: Wed, 7 May 2025 16:40:39 +0800 Subject: [PATCH] refactor: replace OpenFile with Open --- convert/from_curl.go | 2 +- internal/builtin/utils.go | 2 +- internal/version/VERSION | 2 +- pkg/gadb/device.go | 4 ++-- summary.go | 2 +- uixt/android_driver_adb.go | 2 +- uixt/ios_driver_wda.go | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/convert/from_curl.go b/convert/from_curl.go index 8daa46ea..4ad04d90 100644 --- a/convert/from_curl.go +++ b/convert/from_curl.go @@ -119,7 +119,7 @@ func LoadCurlCase(path string) (*hrp.TestCaseDef, error) { } func readFileLines(path string) ([]string, error) { - file, err := os.OpenFile(path, os.O_RDONLY, 0o600) + file, err := os.Open(path) if err != nil { log.Error().Err(err).Str("path", path).Msg("open file failed") return nil, err diff --git a/internal/builtin/utils.go b/internal/builtin/utils.go index 7e6aabcf..638fcef5 100644 --- a/internal/builtin/utils.go +++ b/internal/builtin/utils.go @@ -493,7 +493,7 @@ func RunCommandWithCallback(cmdName string, args []string, callback LineCallback // LoadImage loads image file and returns base64 encoded string and image size func LoadImage(imagePath string) (base64Str string, size types.Size, err error) { // Read the image file - imageFile, err := os.OpenFile(imagePath, os.O_RDONLY, 0o600) + imageFile, err := os.Open(imagePath) if err != nil { return "", types.Size{}, fmt.Errorf("failed to open image file: %w", err) } diff --git a/internal/version/VERSION b/internal/version/VERSION index 5c46e3eb..661dafd1 100644 --- a/internal/version/VERSION +++ b/internal/version/VERSION @@ -1 +1 @@ -v5.0.0-beta-2505060057 +v5.0.0-beta-2505071640 diff --git a/pkg/gadb/device.go b/pkg/gadb/device.go index f4215a58..75bb376a 100644 --- a/pkg/gadb/device.go +++ b/pkg/gadb/device.go @@ -536,7 +536,7 @@ func (d *Device) List(remotePath string) (devFileInfos []DeviceFileInfo, err err } func (d *Device) PushFile(localPath, remotePath string, modification ...time.Time) (err error) { - localFile, err := os.OpenFile(localPath, os.O_RDONLY, 0o600) + localFile, err := os.Open(localPath) if err != nil { return err } @@ -645,7 +645,7 @@ func (d *Device) installViaABBExec(apk io.ReadSeeker, args ...string) (raw []byt } func (d *Device) InstallAPK(apkPath string, args ...string) (string, error) { - apkFile, err := os.OpenFile(apkPath, os.O_RDONLY, 0o600) + apkFile, err := os.Open(apkPath) if err != nil { return "", errors.Wrap(err, fmt.Sprintf("open apk file %s failed", apkPath)) } diff --git a/summary.go b/summary.go index ab6892a7..8fb89557 100644 --- a/summary.go +++ b/summary.go @@ -95,7 +95,7 @@ func (s *Summary) GenHTMLReport() error { } reportPath := filepath.Join(reportsDir, "report.html") - file, err := os.OpenFile(reportPath, os.O_WRONLY|os.O_CREATE, 0o600) + file, err := os.Open(reportPath) if err != nil { log.Error().Err(err).Msg("open file failed") return err diff --git a/uixt/android_driver_adb.go b/uixt/android_driver_adb.go index 7565a066..2c663fa4 100644 --- a/uixt/android_driver_adb.go +++ b/uixt/android_driver_adb.go @@ -699,7 +699,7 @@ func (ad *ADBDriver) StopCaptureLog() (result interface{}, err error) { return pointRes, nil } - reader, err := os.OpenFile(files[0], os.O_RDONLY, 0o600) + reader, err := os.Open(files[0]) if err != nil { log.Info().Msg("open File error") return pointRes, nil diff --git a/uixt/ios_driver_wda.go b/uixt/ios_driver_wda.go index 4cbd8e1d..7ff4f514 100644 --- a/uixt/ios_driver_wda.go +++ b/uixt/ios_driver_wda.go @@ -978,7 +978,7 @@ func (wd *WDADriver) StartCaptureLog(identifier ...string) error { func (wd *WDADriver) PushImage(localPath string) error { log.Info().Str("localPath", localPath).Msg("WDADriver.PushImage") - localFile, err := os.OpenFile(localPath, os.O_RDONLY, 0o600) + localFile, err := os.Open(localPath) if err != nil { return err }