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 { if val, ok := c.pieces[m.Index()]; ok {
return val return val
} }
return nil return &PieceFake{}
} }
func (c *Cache) Close() error { 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" "server/torr/storage"
"github.com/anacrolix/torrent/metainfo" "github.com/anacrolix/torrent/metainfo"
storage2 "github.com/anacrolix/torrent/storage" ts "github.com/anacrolix/torrent/storage"
) )
type Storage struct { type Storage struct {
@@ -24,17 +24,21 @@ func NewStorage(capacity int64) *Storage {
return stor 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() s.mu.Lock()
defer s.mu.Unlock() defer s.mu.Unlock()
ch := NewCache(s.capacity, s) ch := NewCache(s.capacity, s)
ch.Init(info, infoHash) ch.Init(info, infoHash)
s.caches[infoHash] = ch s.caches[infoHash] = ch
return ch, nil return ch, nil
// return storage2.TorrentImpl{ // return ts.TorrentImpl{
// Piece: ch.Piece, // Piece: ch.Piece,
// Close: ch.Close, // Close: ch.Close,
// }, nil // Capacity: &capFunc,
// }, nil
} }
func (s *Storage) CloseHash(hash metainfo.Hash) { func (s *Storage) CloseHash(hash metainfo.Hash) {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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