Merge branch 'master' into old-engine

This commit is contained in:
nikk gitanes
2023-10-05 03:48:16 +03:00
9 changed files with 52 additions and 15 deletions

View File

@@ -83,7 +83,7 @@ func (c *Cache) Piece(m metainfo.Piece) storage.PieceImpl {
if val, ok := c.pieces[m.Index()]; ok {
return val
}
return nil
return &PieceFake{}
}
func (c *Cache) Close() error {

View File

@@ -0,0 +1,33 @@
package torrstor
import (
"errors"
"github.com/anacrolix/torrent/storage"
)
type PieceFake struct{}
func (PieceFake) ReadAt(p []byte, off int64) (n int, err error) {
err = errors.New("fake")
return
}
func (PieceFake) WriteAt(p []byte, off int64) (n int, err error) {
err = errors.New("fake")
return
}
func (PieceFake) MarkComplete() error {
return errors.New("fake")
}
func (PieceFake) MarkNotComplete() error {
return errors.New("fake")
}
func (PieceFake) Completion() storage.Completion {
return storage.Completion{
Complete: false,
Ok: true,
}
}

View File

@@ -6,7 +6,7 @@ import (
"server/torr/storage"
"github.com/anacrolix/torrent/metainfo"
storage2 "github.com/anacrolix/torrent/storage"
ts "github.com/anacrolix/torrent/storage"
)
type Storage struct {
@@ -24,16 +24,20 @@ func NewStorage(capacity int64) *Storage {
return stor
}
func (s *Storage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (storage2.TorrentImpl, error) {
func (s *Storage) OpenTorrent(info *metainfo.Info, infoHash metainfo.Hash) (ts.TorrentImpl, error) {
capFunc := func() (int64, bool) {
return s.capacity, true
}
s.mu.Lock()
defer s.mu.Unlock()
ch := NewCache(s.capacity, s)
ch.Init(info, infoHash)
s.caches[infoHash] = ch
return ch, nil
// return storage2.TorrentImpl{
// return ts.TorrentImpl{
// Piece: ch.Piece,
// Close: ch.Close,
// Capacity: &capFunc,
// }, nil
}

View File

@@ -21,6 +21,7 @@ const TorrentFunctions = memo(
axios.post(viewedHost(), { action: 'rem', hash, file_index: -1 }).then(() => setViewedFileList())
const fullPlaylistLink = `${playlistTorrHost()}/${encodeURIComponent(name || title || 'file')}.m3u?link=${hash}&m3u`
const partialPlaylistLink = `${fullPlaylistLink}&fromlast`
const magnet = `magnet:?xt=urn:btih:${hash}&dn=${encodeURIComponent(name || title)}`
return (
<>
@@ -73,7 +74,7 @@ const TorrentFunctions = memo(
</Button>
</a>
)}
<CopyToClipboard text={hash}>
<CopyToClipboard text={magnet}>
<Button variant='contained' color='primary' size='large'>
{t('CopyHash')}
</Button>

View File

@@ -136,7 +136,7 @@ export const TorrentCardDescription = styled.div`
}
.description-torrent-title {
overflow: auto;
overflow: hidden;
word-break: break-all;
}
@@ -165,7 +165,6 @@ export const TorrentCardDescription = styled.div`
.description-statistics-element-value {
margin-bottom: 10px;
margin-left: 0;
word-break: break-all;
@media (max-width: 1260px), (max-height: 500px) {
font-size: 0.7rem;
@@ -181,7 +180,7 @@ export const TorrentCardDescription = styled.div`
}
@media (max-width: 410px) {
font-size: 10px;
font-size: 9px;
}
}
`}

View File

@@ -31,7 +31,7 @@
"Close": "Close",
"CloseServer?": "Do you want to turn off server?",
"CloseServer": "Turn Off",
"CopyHash": "Copy Hash",
"CopyHash": "Copy Magnet",
"CopyLink": "Copy link",
"Data": "Data",
"DebugMode": "Download priorities",

View File

@@ -31,7 +31,7 @@
"Close": "Закрыть",
"CloseServer?": "Хотите выключить сервер?",
"CloseServer": "Выкл. сервер",
"CopyHash": "Скопировать хеш",
"CopyHash": "Скопировать Magnet",
"CopyLink": "Копировать",
"Data": "Данные",
"DebugMode": "Метки приоритетов",

View File

@@ -31,7 +31,7 @@
"Close": "Закрити",
"CloseServer?": "Хочете вимкнути сервер?",
"CloseServer": "Вимк. сервер",
"CopyHash": "Скопіювати хеш",
"CopyHash": "Скопіювати Magnet",
"CopyLink": "Копіювати",
"Data": "Дані",
"DebugMode": "Мітки пріоритетів",

View File

@@ -31,7 +31,7 @@
"Close": "关闭",
"CloseServer?": "你想关闭服务器吗?",
"CloseServer": "关闭",
"CopyHash": "复制哈希",
"CopyHash": "复制磁力链接",
"CopyLink": "复制链接",
"Data": "数据",
"DebugMode": "优先级标记",