Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
Remove metadata file before Rename call in Windows.
Browse files Browse the repository at this point in the history
Issue #64.
  • Loading branch information
Matt Pharr committed Apr 27, 2015
1 parent 96a1286 commit 19c9e2f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gdrive/gdrive.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,14 @@ func (gd *GDrive) saveMetadataCache(filename string, maxChangeId int64,
} else if err := flocal.Close(); err != nil {
return err
}

// Windows doesn't let us rename one file on top of an existing
// one. Therefore, when running on Windows, remove the target file
// first.
if runtime.GOOS == "windows" {
_ = os.Remove(filename)
}

if err := os.Rename(flocal.Name(), filename); err != nil {
return err
}
Expand Down

0 comments on commit 19c9e2f

Please sign in to comment.