Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,19 @@ func (ldb *LiteDB) create(ctx scope.C, opts *SnapshotOptions, now time.Time, sco
}

func (ldb *LiteDB) touch(path string) error {
// ensure snapshots directory exists with owner-only permissions
directory := filepath.Dir(path)
if err := os.MkdirAll(directory, 0700); err != nil {
return err
}

// ensure the snapshot file exists with owner-only permissions
file, err := os.OpenFile(path, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600)
if err != nil {
return err
}

// close the file; sqlite will re-open it with the existing permissions
return file.Close()
}

Expand Down