From 76968c9afdd94e0a0c2af6fdd8df306952684806 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cenk=20Alt=C4=B1?= Date: Wed, 18 Sep 2024 14:30:08 -0400 Subject: [PATCH] rename RootDirectory to Dir --- torrent/session_cmd.go | 2 +- torrent/session_torrent.go | 7 +++---- torrent/torrent.go | 2 +- torrent/torrent_test.go | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/torrent/session_cmd.go b/torrent/session_cmd.go index 1d8461b5..3307f9b2 100644 --- a/torrent/session_cmd.go +++ b/torrent/session_cmd.go @@ -21,7 +21,7 @@ func (s *Session) runOnCompleteCmd(torrent *torrent) { cmd.Env = append(os.Environ(), "RAIN_TORRENT_ADDED="+fmt.Sprint(torrent.addedAt.Unix()), - "RAIN_TORRENT_DIR="+torrent.storage.RootDir(), + "RAIN_TORRENT_DIR="+torrent.Dir(), "RAIN_TORRENT_HASH="+hex.EncodeToString(torrent.infoHash[:]), "RAIN_TORRENT_ID="+torrent.id, "RAIN_TORRENT_NAME="+torrent.name) diff --git a/torrent/session_torrent.go b/torrent/session_torrent.go index 6a344914..3036e6f7 100644 --- a/torrent/session_torrent.go +++ b/torrent/session_torrent.go @@ -42,10 +42,9 @@ func (t *Torrent) Name() string { return t.torrent.Name() } -// RootDirectory of the torrent. -// The directory that contains the files in the torrent. -func (t *Torrent) RootDirectory() string { - return t.torrent.RootDirectory() +// Dir returns the directory that contains the files in the torrent. +func (t *Torrent) Dir() string { + return t.torrent.Dir() } // Files in the torrent. An error is returned when metainfo isn't ready. diff --git a/torrent/torrent.go b/torrent/torrent.go index d74f3f74..b818c001 100644 --- a/torrent/torrent.go +++ b/torrent/torrent.go @@ -414,7 +414,7 @@ func (t *torrent) InfoHash() []byte { return b } -func (t *torrent) RootDirectory() string { +func (t *torrent) Dir() string { return t.storage.RootDir() } diff --git a/torrent/torrent_test.go b/torrent/torrent_test.go index 2bb4f5ea..b02f494d 100644 --- a/torrent/torrent_test.go +++ b/torrent/torrent_test.go @@ -151,7 +151,7 @@ func TestDownloadTorrent(t *testing.T) { assertCompleted(t, tor) } -func TestTorrentRootDirectory(t *testing.T) { +func TestTorrentDir(t *testing.T) { defer leaktest.Check(t)() addr, cl := seeder(t, true) defer cl() @@ -162,7 +162,7 @@ func TestTorrentRootDirectory(t *testing.T) { if err != nil { t.Fatal(err) } - assert.Equal(t, filepath.Join(s.config.DataDir, tor.ID()), tor.RootDirectory()) + assert.Equal(t, filepath.Join(s.config.DataDir, tor.ID()), tor.Dir()) assertCompleted(t, tor) }