Skip to content

Commit

Permalink
fix builtinobjects.go: use tempdir (#93)
Browse files Browse the repository at this point in the history
* fix builtinobjects.go: use tempdir
  • Loading branch information
requilence authored Jun 13, 2023
1 parent e41af55 commit 0fa0c62
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util/builtinobjects/builtinobjects.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
_ "embed"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"time"
Expand Down Expand Up @@ -122,7 +123,11 @@ func (b *builtinObjects) InjectMigrationDashboard() error {
}

func (b *builtinObjects) inject(ctx *session.Context, archive []byte, isMigration bool) (err error) {
path := filepath.Join("./", time.Now().Format("tmp.20060102.150405.99")+".zip")
tempDir, err := ioutil.TempDir(os.TempDir(), "anytype_tmp*")
if err != nil {
return err
}
path := filepath.Join(tempDir, time.Now().Format("tmp.20060102.150405.99")+".zip")
if err = os.WriteFile(path, archive, 0644); err != nil {
return fmt.Errorf("failed to save use case archive to temporary file: %s", err.Error())
}
Expand Down

0 comments on commit 0fa0c62

Please sign in to comment.