Skip to content

Commit

Permalink
feat(btrfs): use relative symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
idawnlight committed Dec 1, 2023
1 parent 52cc16a commit 783b934
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions worker/btrfs_snapshot_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,13 @@ func (h *btrfsSnapshotHook) postSuccess() error {
workingDir := h.config.mirrorWorkingDir
newSnapshot := h.config.NewSnapshotName()
newSnapshotPath := filepath.Join(h.config.mirrorSnapshotDir, newSnapshot)
relativePath, err := filepath.Rel(h.config.mirrorServeDir, newSnapshotPath)
if err != nil {
return err
}

// create ro snapshot
err := tryCreateSnapshot(workingDir, newSnapshotPath, true)
err = tryCreateSnapshot(workingDir, newSnapshotPath, true)
if err != nil {
return err
}
Expand All @@ -241,7 +245,7 @@ func (h *btrfsSnapshotHook) postSuccess() error {
logger.Errorf("failed to remove symlink %s: %s", h.config.mirrorServeDir+".tmp", err.Error())
return err
}
if err := os.Symlink(newSnapshotPath, h.config.mirrorServeDir+".tmp"); err != nil {
if err := os.Symlink(relativePath, h.config.mirrorServeDir+".tmp"); err != nil {
logger.Errorf("failed to create symlink %s: %s", h.config.mirrorServeDir+".tmp", err.Error())
return err
}
Expand Down

0 comments on commit 783b934

Please sign in to comment.