xssnick / tonutils-storage

TON Storage golang implementation
Apache License 2.0
47 stars 8 forks source link

panic on creating torrent #4

Closed IgorShadurin closed 1 year ago

IgorShadurin commented 1 year ago

During running create /Users/test/Downloads/GUI.Mac.M1.Tonutils.Proxy.dmg bbb command I received error:

▀  Scanning files... (0s)panic: runtime error: slice bounds out of range [52:51]

goroutine 1 [running]:
github.com/xssnick/tonutils-storage/storage.CreateTorrent.func1({0x1400020a587, 0x33}, {0x100ef8db0?, 0x14000074a90?}, {0x0?, 0x0?})
    /Users/xssnick/dev/ton/tonutils-storage/storage/create.go:62 +0x4dc
path/filepath.walk({0x1400020a587, 0x33}, {0x100ef8db0, 0x14000074a90}, 0x140001e6ec0)
    /usr/local/go/src/path/filepath/path.go:433 +0xd0
path/filepath.Walk({0x1400020a587, 0x33}, 0x140001e6ec0)
    /usr/local/go/src/path/filepath/path.go:520 +0x6c
github.com/xssnick/tonutils-storage/storage.CreateTorrent({0x1400020a587, 0x33}, {0x1400020a5bb, 0x3}, {0x100ef9798, 0x1400023ecc0}, {0x100ef9460, 0x14000226840})
    /Users/xssnick/dev/ton/tonutils-storage/storage/create.go:53 +0x270
main.create({0x1400020a587?, 0x3e?}, {0x1400020a5bb?, 0x1?})
    /Users/xssnick/dev/ton/tonutils-storage/cli/main.go:245 +0x4c
main.main()
    /Users/xssnick/dev/ton/tonutils-storage/cli/main.go:192 +0x12e0
xssnick commented 1 year ago

You should specify path of directory to create torrent from (not file).

Thank you for the issue, I will test and will also add support for creation from files.

xssnick commented 1 year ago

v0.2.0 Released with support of creation from files, could you please try again?

IgorShadurin commented 1 year ago

Now separate files are added without errors. Information about the file from the local machine is visible on the VPS. But the file is not downloading. Directories are loaded normally.

In the "Completed" row, the value for files is false, for the directory - true.

xssnick commented 1 year ago

Released v0.2.1, Included fix for this too, check please

IgorShadurin commented 1 year ago

If I create a torrent from a file like this create ./GUI.Mac.M1.Tonutils.Proxy.dmg aaa or like this create ton-torrent-mac-apple-silicon.dmg zzz111 it causes problems on the downloader side (using the official client). FATAL ERROR: Invalid torrent header: Invalid torrent header: Invalid dir_name: Name can't start with '/'.

xssnick commented 1 year ago

If I create a torrent from a file like this create ./GUI.Mac.M1.Tonutils.Proxy.dmg aaa or like this create ton-torrent-mac-apple-silicon.dmg zzz111 it causes problems on the downloader side (using the official client). FATAL ERROR: Invalid torrent header: Invalid torrent header: Invalid dir_name: Name can't start with '/'.

Fixed in v0.2.2

IgorShadurin commented 1 year ago

The server is unable to download a single file with the new version. However, the downloading of directories proceeds without issue. Official client can get the name of the file, but the download process for the file simply has not started. The file was added using the command create ton-torrent-mac-apple-silicon.dmg macsil.

Screenshot 2023-06-18 at 00 07 32
xssnick commented 1 year ago

The server is unable to download a single file with the new version. However, the downloading of directories proceeds without issue. Official client can get the name of the file, but the download process for the file simply has not started. The file was added using the command create ton-torrent-mac-apple-silicon.dmg macsil.

Screenshot 2023-06-18 at 00 07 32

I changed behavior in v0.2.3, it will work between tonutils-storage nodes. But not sure about storage-daemon, I think it may not work with empty directory names, so single file torrents may be incompatible by design.

For now you can use single file torrents with tonutils-storage

xssnick commented 1 year ago

Tested v0.2.3 with storage-daemon, works fine too.