Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov committed Sep 14, 2023
1 parent ffd19ea commit d72b94c
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions downloader/downloader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,18 @@ func TestChangeInfoHashOfSameFile(t *testing.T) {
require.Equal("a.seg", tt.Name())

// allow adding files only if they are insidesnapshots dir
require.NoError(BuildTorrentIfNeed(ctx, "a.seg", dirs.Snap))
require.NoError(BuildTorrentIfNeed(ctx, "b/a.seg", dirs.Snap))
require.NoError(BuildTorrentIfNeed(ctx, filepath.Join(dirs.Snap, "a.seg"), dirs.Snap))
require.NoError(BuildTorrentIfNeed(ctx, filepath.Join(dirs.Snap, "b", "a.seg"), dirs.Snap))
_, err = BuildTorrentIfNeed(ctx, "a.seg", dirs.Snap)
require.NoError(err)
_, err = BuildTorrentIfNeed(ctx, "b/a.seg", dirs.Snap)
require.NoError(err)
_, err = BuildTorrentIfNeed(ctx, filepath.Join(dirs.Snap, "a.seg"), dirs.Snap)
require.NoError(err)
_, err = BuildTorrentIfNeed(ctx, filepath.Join(dirs.Snap, "b", "a.seg"), dirs.Snap)
require.NoError(err)

// reject escaping snapshots dir
require.Error(BuildTorrentIfNeed(ctx, filepath.Join(dirs.Chaindata, "b", "a.seg"), dirs.Snap))
require.Error(BuildTorrentIfNeed(ctx, "./../a.seg", dirs.Snap))
_, err = BuildTorrentIfNeed(ctx, filepath.Join(dirs.Chaindata, "b", "a.seg"), dirs.Snap)
require.Error(err)
_, err = BuildTorrentIfNeed(ctx, "./../a.seg", dirs.Snap)
require.Error(err)
}

0 comments on commit d72b94c

Please sign in to comment.