Skip to content

Commit

Permalink
Implement DB.ImportFromFile and deprecate DB.Import
Browse files Browse the repository at this point in the history
  • Loading branch information
philippgille committed May 4, 2024
1 parent 0db48ae commit 472e2d0
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,21 @@ func NewPersistentDB(path string, compress bool) (*DB, error) {
//
// - filePath: Mandatory, must not be empty
// - encryptionKey: Optional, must be 32 bytes long if provided
//
// Deprecated: Use [DB.ImportFromFile] instead.
func (db *DB) Import(filePath string, encryptionKey string) error {
return db.ImportFromFile(filePath, encryptionKey)
}

// ImportFromFile imports the DB from a file at the given path. The file must be
// encoded as gob and can optionally be compressed with flate (as gzip) and encrypted
// with AES-GCM.
// This works for both the in-memory and persistent DBs.
// Existing collections are overwritten.
//
// - filePath: Mandatory, must not be empty
// - encryptionKey: Optional, must be 32 bytes long if provided
func (db *DB) ImportFromFile(filePath string, encryptionKey string) error {
if filePath == "" {
return fmt.Errorf("file path is empty")
}
Expand Down

0 comments on commit 472e2d0

Please sign in to comment.