mirror of
https://github.com/httprunner/httprunner.git
synced 2026-06-25 17:44:02 +08:00
refactor: replace OpenFile with Open
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
v5.0.0-beta-2505060057
|
||||
v5.0.0-beta-2505071640
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user