make relative links when the canonical and new db paths are in the same directory
This commit is contained in:
parent
950ded454d
commit
0740274b7c
@ -355,7 +355,7 @@ func (b *Blockstore) movingGC() error {
|
||||
panic(fmt.Errorf("error renaming old badger db dir from %s to %s: %w; USER ACTION REQUIRED", dbPath, backupPath, err)) //nolint
|
||||
}
|
||||
|
||||
if err = os.Symlink(newPath, dbPath); err != nil {
|
||||
if err = b.symlink(newPath, dbPath); err != nil {
|
||||
// same here; the db path is pointing to the void. panic and let the user fix.
|
||||
panic(fmt.Errorf("error symlinking new badger db dir from %s to %s: %w; USER ACTION REQUIRED", newPath, dbPath, err)) //nolint
|
||||
}
|
||||
@ -367,6 +367,18 @@ func (b *Blockstore) movingGC() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// symlink creates a symlink from path to linkPath; the link is relative if the two are
|
||||
// in the same directory
|
||||
func (b *Blockstore) symlink(path, linkTo string) error {
|
||||
pathDir := filepath.Dir(path)
|
||||
linkDir := filepath.Dir(linkTo)
|
||||
if pathDir == linkDir {
|
||||
path = filepath.Base(path)
|
||||
}
|
||||
|
||||
return os.Symlink(path, linkTo)
|
||||
}
|
||||
|
||||
// doCopy copies a badger blockstore to another, with an optional filter; if the filter
|
||||
// is not nil, then only cids that satisfy the filter will be copied.
|
||||
func (b *Blockstore) doCopy(from, to *badger.DB) error {
|
||||
|
Loading…
Reference in New Issue
Block a user