Ticket #3100 (closed enhancement: fixed)

Opened 11 years ago

Last modified 10 days ago

Embedded torrent viewer/vfs

Reported by: eugenesan Owned by: zaytsev
Priority: major Milestone: 4.8.33
Component: mc-vfs Version: master
Keywords: torrent ext vfs Cc: phd@…
Blocked By: Blocking:
Branch state: merged Votes for changeset: committed-master

Description

Currently ext.d viewer for torrent is partially broken since ctorrent is used and it broken in most distributions (http://sourceforge.net/p/dtorrent/bugs/21/).

Attached patch adds viewer and vfs support based on script found here: http://phdru.name/Software/mc/torrent

Attachments

ext_embedded_torrent.patch (11.4 KB) - added by eugenesan 11 years ago.
Embed torrent viewer/vfs
add-support-for-internal-torrent-viewer-vfs.patch (16.8 KB) - added by eugenesan 11 years ago.
support kernel initrd images as VFS
0001-extfs-Add-support-for-BitTorrent-file-browse.patch (8.7 KB) - added by artemsen 6 years ago.
folder.torrent (166 bytes) - added by zaytsev 3 weeks ago.
Screenshot 2025-01-11 at 16.21.12.png (1.2 MB) - added by zaytsev 3 weeks ago.

Change History

Changed 11 years ago by eugenesan

Embed torrent viewer/vfs

comment:1 Changed 11 years ago by slavazanko

  • Owner set to slavazanko
  • Status changed from new to accepted
  • Branch state changed from no branch to on rework

Created branch 3100_torrent
Initial changeset:10401bb70eb846261da1e51f4c6e3a751995ae8f

But branch is stayed in 'on rework' stage because have an issue with viewing .torrent files (via F3):

./torrent view some-file.torrent 
Unknown command view
Last edited 11 years ago by slavazanko (previous) (diff)

Changed 11 years ago by eugenesan

support kernel initrd images as VFS

comment:2 Changed 11 years ago by eugenesan

Fixed and refreshed the patch

comment:3 Changed 11 years ago by andrew_b

  • Milestone changed from 4.8.11 to 4.8.12

comment:4 Changed 10 years ago by andrew_b

  • Milestone changed from 4.8.12 to Future Releases

Changed 6 years ago by artemsen

comment:5 Changed 6 years ago by artemsen

  • Component changed from mc-core to mc-vfs
  • Branch state changed from on rework to on review

comment:6 follow-up: ↓ 8 Changed 6 years ago by andrew_b

Is python3 required?

comment:7 Changed 6 years ago by andrew_b

  • Branch state changed from on review to no branch

comment:8 in reply to: ↑ 6 ; follow-up: ↓ 9 Changed 6 years ago by artemsen

Replying to andrew_b:

Is python3 required?

Yes, python3 is required. Does MC have restrictions with that?

comment:9 in reply to: ↑ 8 ; follow-up: ↓ 10 Changed 6 years ago by andrew_b

Replying to artemsen:

Yes, python3 is required. Does MC have restrictions with that?

Generally no. extfs plugins written in python don't have explicit python version in shebang (#3936). Using pyhon3 explicitly can break the portability. Some systems where mc is used may not have python3.

comment:10 in reply to: ↑ 9 Changed 6 years ago by artemsen

Replying to andrew_b:

extfs plugins written in python don't have explicit python version in shebang (#3936). Using pyhon3 explicitly can break the portability.

Do you suggest to use MC's shebang that was set by configure script? I don't think it's a good idea to use /usr/bin/python because it may point to python2 as well as to python3, meanwhile the usual shebang '#!/usr/bin/env python3' is a system independent solution.

Some systems where mc is used may not have python3.

Yes, but these system may not have python2 or even bash, so...
Anyway, this plugin is not a mandatory component and it doesn't brake general MC functionality.

comment:11 follow-up: ↓ 12 Changed 3 weeks ago by zaytsev

  • Cc phd@… added

Nowadays Python 2 is deprecated and unsupported, all active distributions should ship Python 3 and install it under the name of python3. Sometimes python is linked to python3 for compatibility, sometimes not - like on macOS.

The best way to pick correct interpreter is #!/usr/bin/env python3 for the users. Distros might want to force their system interpreter at configure time, so I don't know how happy they are going to be about our change to #!/usr/bin/env. I guess they won't like it.

Upon reflection, I would actually suggest to revert the removal of PYTHON for both Python extfs scripts. But in any case we should be consistent. I can re-add in cleanup of #4572 and drop my recent commit. Andrew, what do you think?

Regarding the torrent module, it seems to be maintained by the author, but it references an external file. This is problematic for us. If the file is merged into the script, I think we could take it, but only if author will provide us with updates in the future. If we take it and then it rots, this will be annoying.

Putting author on CC.

comment:12 in reply to: ↑ 11 Changed 3 weeks ago by phd

The best way to pick correct interpreter is #!/usr/bin/env python3

This is how I do it by default.

Regarding the torrent module, it seems to be maintained by the author, but it references an external file.

I need a bencode decoder. I must say the current one is outdated; I modernized it a bit but it would be better to replace it completely. But I still need one.

Putting author on CC.

Hello, everyone! Thank you for maintaining MC! I use it since about 1995, when it was at mc.mx domain. :-)

comment:13 Changed 3 weeks ago by zaytsev

Ticket #2656 has been marked as a duplicate of this ticket.

comment:14 follow-up: ↓ 15 Changed 3 weeks ago by zaytsev

I need a bencode decoder.

I don't object to that. It's just that we want embedded extfs scripts to be 1-file only, so if you can put everything in 1 file that would be great.

Thank you for maintaining MC! I use it since about 1995, when it was at mc.mx domain.

Thank you! I've been using it since around that time on FreeBSD as well, but otherwise I'm quite new here, started contributing about 15 years ago...

comment:15 in reply to: ↑ 14 Changed 3 weeks ago by phd

Replying to zaytsev:

I need a bencode decoder.

I don't object to that. It's just that we want embedded extfs scripts to be 1-file only, so if you can put everything in 1 file that would be great.

https://git.phdru.name/?p=extfs.d.git;a=commitdiff;h=c73cf5c5d0f15c0c3460acdb4463aa2d3ecf1fb5

Thank you for maintaining MC! I use it since about 1995, when it was at mc.mx domain.

Thank you! I've been using it since around that time on FreeBSD as well, but otherwise I'm quite new here, started contributing about 15 years ago...

:-)))

Changed 3 weeks ago by zaytsev

Changed 3 weeks ago by zaytsev

comment:16 follow-up: ↓ 17 Changed 3 weeks ago by zaytsev

  • Owner changed from slavazanko to zaytsev
  • Milestone changed from Future Releases to 4.8.33

I have rebased the branch:

Branch: 3100_torrent
Initial changeset: cff091daf9e8b8e94e6979ca6476415ac4d22faf

Tried some files from the web:

https://github.com/webtorrent/webtorrent-fixtures/tree/master/fixtures

folder.torrent somehow doesn't work.

I wonder how we can integrate a test in our test suite? Do you have a good test file?

comment:17 in reply to: ↑ 16 Changed 3 weeks ago by phd

Tried some files from the web:

https://github.com/webtorrent/webtorrent-fixtures/tree/master/fixtures

folder.torrent somehow doesn't work.

Interesting:

$ ~/.mc/extfs.d/torrent list folder.torrent
dr-xr-xr-x 1 user group 0 02-13-47910 02:30 .META
dr-xr-xr-x 1 user group 0 02-13-47910 02:30 folder
-r--r--r-- 1 user group 25 02-13-47910 02:30 .META/creation date
-r--r--r-- 1 user group 5 02-13-47910 02:30 .META/encoding
-r--r--r-- 1 user group 5 02-13-47910 02:30 .META/piece length
-r--r--r-- 1 user group 15 02-13-47910 02:30 folder/file.txt

The script works, but meaningless year breaks parsing in MC. creation date in the torrent file is set to 1449730049429. What should I do? Report an error and abort? Cut the year to something more meaningful like 2100?

I wonder how we can integrate a test in our test suite? Do you have a good test file?

I don't. I can think of creating a standalone (not related to MC) test suite but it would require some tie for development. Thank you for pointing to interesting test torrents!

comment:18 follow-up: ↓ 19 Changed 3 weeks ago by zaytsev

  • Branch state changed from no branch to on review

The script works, but meaningless year breaks parsing in MC. creation date in the torrent file is set to 1449730049429. What should I do?

I would set the year to 9999. In the perfect world, aborting with an error message would be best, but I guess file manager users would want the manager to deal with non-fatally corrupted files.

I don't.

Well, I have added sintel.torrent to our test suite from this link. I had to make some changes to make the script testable and fix a problem on Solaris, you can see the development here:

https://github.com/MidnightCommander/mc/compare/master...3100_torrent

Now all tests pass.

comment:19 in reply to: ↑ 18 Changed 3 weeks ago by phd

Replying to zaytsev:

I would set the year to 9999.

https://git.phdru.name/?p=extfs.d.git;a=commitdiff;h=54decb72d473126554258d7c1677745ea1c7a8c4


$ ~/.mc/extfs.d/torrent list folder.torrent
dr-xr-xr-x 1 user group 0 02-13-9999 02:30 .META
dr-xr-xr-x 1 user group 0 02-13-9999 02:30 folder
-r--r--r-- 1 user group 25 02-13-9999 02:30 .META/creation date
-r--r--r-- 1 user group 5 02-13-9999 02:30 .META/encoding
-r--r--r-- 1 user group 5 02-13-9999 02:30 .META/piece length
-r--r--r-- 1 user group 15 02-13-9999 02:30 folder/file.txt

Last edited 3 weeks ago by phd (previous) (diff)

comment:20 Changed 3 weeks ago by zaytsev

Cool, pulled into our tree, thank you! It would be great if you would provide us with patches against our version upon updates. Ready for review...

comment:21 Changed 3 weeks ago by andrew_b

I've changed

@EXTHELPERSDIR@/../extfs.d/torrent list "${MC_EXT_FILENAME}" 2>/dev/null

using new variable:

@EXTFSHELPERSDIR@/torrent list "${MC_EXT_FILENAME}" 2>/dev/null

I think this is more correct way.

comment:22 Changed 3 weeks ago by zaytsev

Sorry, I agree! Took over from Slava, only replaced view with list...

comment:23 Changed 3 weeks ago by zaytsev

  • Votes for changeset set to zaytsev

comment:24 Changed 2 weeks ago by andrew_b

  • Votes for changeset changed from zaytsev to zaytsev andrew_b
  • Branch state changed from on review to approved

comment:25 Changed 2 weeks ago by zaytsev

  • Status changed from accepted to testing
  • Votes for changeset changed from zaytsev andrew_b to committed-master
  • Resolution set to fixed
  • Branch state changed from approved to merged

comment:26 Changed 2 weeks ago by zaytsev

  • Status changed from testing to closed

comment:27 Changed 10 days ago by zaytsev

Note: See TracTickets for help on using tickets.