Skip to content
This repository has been archived by the owner on Oct 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #23 from togls/master
Browse files Browse the repository at this point in the history
fix: print error message when update token file
  • Loading branch information
LinkLeong authored Nov 26, 2021
2 parents 75391f9 + 28620f9 commit 88dd30e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions aliyun/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package aliyun

import (
"encoding/json"
"errors"
"fmt"
"go-aliyun-webdav/aliyun/cache"
"go-aliyun-webdav/aliyun/model"
Expand Down Expand Up @@ -140,14 +141,18 @@ func RefreshToken(refreshToken string) model.RefreshTokenModel {
return refresh
}

if _, err := os.Stat(path); err != nil {
fmt.Printf("RefreshToken Err=%s", err)
_, err = os.Stat(path)
if errors.Is(err, os.ErrNotExist) {
return refresh
}
if err != nil {
fmt.Println("更新token文件失败,失败信息", err)
return refresh
}

err = ioutil.WriteFile(path, []byte(refresh.RefreshToken), 0600)
if err != nil {
fmt.Printf("RefreshToken Err=%s", err)
fmt.Println("更新token文件失败,失败信息", err)
}

return refresh
Expand Down

0 comments on commit 88dd30e

Please sign in to comment.