diff --git a/server/torr/storage/torrstor/cache.go b/server/torr/storage/torrstor/cache.go index 3074b31..efe861d 100644 --- a/server/torr/storage/torrstor/cache.go +++ b/server/torr/storage/torrstor/cache.go @@ -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 { diff --git a/server/torr/storage/torrstor/piecefake.go b/server/torr/storage/torrstor/piecefake.go new file mode 100644 index 0000000..6434bb2 --- /dev/null +++ b/server/torr/storage/torrstor/piecefake.go @@ -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, + } +} diff --git a/server/torr/storage/torrstor/storage.go b/server/torr/storage/torrstor/storage.go index 71c25a3..8f49a4e 100644 --- a/server/torr/storage/torrstor/storage.go +++ b/server/torr/storage/torrstor/storage.go @@ -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,17 +24,21 @@ 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{ - // Piece: ch.Piece, - // Close: ch.Close, - // }, nil +// return ts.TorrentImpl{ +// Piece: ch.Piece, +// Close: ch.Close, +// Capacity: &capFunc, +// }, nil } func (s *Storage) CloseHash(hash metainfo.Hash) { diff --git a/web/src/components/DialogTorrentDetailsContent/TorrentFunctions/index.jsx b/web/src/components/DialogTorrentDetailsContent/TorrentFunctions/index.jsx index f5aeebc..64a93f8 100644 --- a/web/src/components/DialogTorrentDetailsContent/TorrentFunctions/index.jsx +++ b/web/src/components/DialogTorrentDetailsContent/TorrentFunctions/index.jsx @@ -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( )} - + diff --git a/web/src/components/TorrentCard/style.js b/web/src/components/TorrentCard/style.js index 006b9da..1348bbf 100644 --- a/web/src/components/TorrentCard/style.js +++ b/web/src/components/TorrentCard/style.js @@ -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; } } `} diff --git a/web/src/locales/en/translation.json b/web/src/locales/en/translation.json index 50dadf5..6e75f7a 100644 --- a/web/src/locales/en/translation.json +++ b/web/src/locales/en/translation.json @@ -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", diff --git a/web/src/locales/ru/translation.json b/web/src/locales/ru/translation.json index 8b13e50..7353b53 100644 --- a/web/src/locales/ru/translation.json +++ b/web/src/locales/ru/translation.json @@ -31,7 +31,7 @@ "Close": "Закрыть", "CloseServer?": "Хотите выключить сервер?", "CloseServer": "Выкл. сервер", - "CopyHash": "Скопировать хеш", + "CopyHash": "Скопировать Magnet", "CopyLink": "Копировать", "Data": "Данные", "DebugMode": "Метки приоритетов", diff --git a/web/src/locales/ua/translation.json b/web/src/locales/ua/translation.json index 1b384bc..ac4756e 100644 --- a/web/src/locales/ua/translation.json +++ b/web/src/locales/ua/translation.json @@ -31,7 +31,7 @@ "Close": "Закрити", "CloseServer?": "Хочете вимкнути сервер?", "CloseServer": "Вимк. сервер", - "CopyHash": "Скопіювати хеш", + "CopyHash": "Скопіювати Magnet", "CopyLink": "Копіювати", "Data": "Дані", "DebugMode": "Мітки пріоритетів", diff --git a/web/src/locales/zh/translation.json b/web/src/locales/zh/translation.json index 92598ae..65decb9 100644 --- a/web/src/locales/zh/translation.json +++ b/web/src/locales/zh/translation.json @@ -31,7 +31,7 @@ "Close": "关闭", "CloseServer?": "你想关闭服务器吗?", "CloseServer": "关闭", - "CopyHash": "复制哈希", + "CopyHash": "复制磁力链接", "CopyLink": "复制链接", "Data": "数据", "DebugMode": "优先级标记",