Skip to content

Commit

Permalink
resourcepacks rework/cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
olebeck committed Jul 16, 2024
1 parent 79b949c commit d02e52b
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 311 deletions.
18 changes: 5 additions & 13 deletions utils/proxy/packcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,30 +46,22 @@ func (c *packCache) Create(id, ver string) (*closeMoveWriter, error) {

_ = os.MkdirAll(filepath.Dir(finalPath), 0777)

f, err := os.Create(tmpPath)
f, err := createTemp(tmpPath)
if err != nil {
return nil, err
}

return &closeMoveWriter{
f: f,
File: f,
FinalName: finalPath,
}, nil
}

type closeMoveWriter struct {
f *os.File
*os.File
FinalName string
}

func (c *closeMoveWriter) Write(b []byte) (n int, err error) {
return c.f.Write(b)
}

func (c *closeMoveWriter) Close() error {
err := c.f.Close()
if err != nil {
return err
}
return os.Rename(c.f.Name(), c.FinalName)
func (c *closeMoveWriter) Move() error {
return os.Rename(c.File.Name(), c.FinalName)
}
Loading

0 comments on commit d02e52b

Please sign in to comment.