Skip to content

Commit

Permalink
feat(store): use use relative path for empty blocks symlinks (#3861)
Browse files Browse the repository at this point in the history
  • Loading branch information
walldiss authored Oct 19, 2024
1 parent 23af20a commit 36fb8c2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions store/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,15 @@ func (s *Store) createODSFile(
}

func (s *Store) linkHeight(datahash share.DataHash, height uint64) error {
// create hard link with height as name
pathOds := s.hashToPath(datahash, odsFileExt)
linktoOds := s.heightToPath(height, odsFileExt)
if datahash.IsEmptyEDS() {
// empty EDS is always symlinked, because there is limited number of hardlinks
// for the same file in some filesystems (ext4)
pathOds := s.hashToRelativePath(datahash, odsFileExt)
return symlink(pathOds, linktoOds)
}
// create hard link with height as name
pathOds := s.hashToPath(datahash, odsFileExt)
return hardLink(pathOds, linktoOds)
}

Expand Down Expand Up @@ -444,6 +445,10 @@ func (s *Store) hashToPath(datahash share.DataHash, ext string) string {
return filepath.Join(s.basepath, blocksPath, datahash.String()) + ext
}

func (s *Store) hashToRelativePath(datahash share.DataHash, ext string) string {
return filepath.Join("..", datahash.String()) + ext
}

func (s *Store) heightToPath(height uint64, ext string) string {
return filepath.Join(s.basepath, heightsPath, strconv.Itoa(int(height))) + ext
}
Expand Down

0 comments on commit 36fb8c2

Please sign in to comment.