Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
movsb committed Jul 10, 2024
1 parent 0b21210 commit 701ddd3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmd/sync/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ func (g *GitSync) syncSingle(p *proto.Post) error {

// 正在编辑且并没提交的文件可能会比远程更新,此时不能覆盖本地的文件。
// TODO 用文件系统而不是 os.
stat := utils.Must1(os.Stat(fullPath))
if stat.ModTime().After(time.Unix(int64(p.Modified), 0)) {
return fmt.Errorf(`本地的文件更新,没有覆盖:%s`, path)
if stat, err := os.Stat(fullPath); err == nil {
if stat.ModTime().After(time.Unix(int64(p.Modified), 0)) {
return fmt.Errorf(`本地的文件更新,没有覆盖:%s`, path)
}
}

if err := ioutil.WriteFile(fullPath, []byte(p.Source), 0644); err != nil {
Expand Down

0 comments on commit 701ddd3

Please sign in to comment.