torf-cli icon indicating copy to clipboard operation
torf-cli copied to clipboard

Torf fails to create torrent if symlink exists in target directory

Open halmartin opened this issue 3 years ago • 1 comments

I was trying to create a torrent of a directory which contained a soft symlink to another file also in the target directory:

$ ls
OVMF_CODE.fd
OVMF_VARS.fd
snapshot.qcow2
base.qcow2
latest.qcow2 -> snapshot.qcow2

Attempting to create a torrent with torf resulted in the following error:

       Name  stuff
       Size  28.48 GiB
    Created  2022-01-05 14:29:00
 Created By  torf 3.4.0
    Private  yes
 Piece Size  8 MiB
Piece Count  3646
 File Count  5
      Files  stuff
             ├─OVMF_CODE.fd [3.48 MiB]
             ├─OVMF_VARS.fd [528 KiB]
             ├─latest.qcow2 [2.55 GiB]
             ├─base.qcow2 [23.38 GiB]
             └─snapshot.qcow2 [2.55 GiB]
   Progress  90.04 % ▕snapshot.qcow2             ▏ 5.69 GiB/s
torf: Invalid metainfo: ['info']['pieces'] is empty

On a hunch, I removed the symlink latest.qcow2 and was able to successfully create the torrent.

I have no suggestion for how to resolve this, I just wanted to document that a symlink will cause torf to fail with an error message which does not clearly indicate the root cause of the failure.

halmartin avatar Jan 05 '22 14:01 halmartin

Thanks for the report.

I think I've seen this with two files that have the same content.

But it's not really worth investigating because the relevant code is very bad and needs a complete rewrite.

rndusr avatar Jan 05 '22 15:01 rndusr

I just tried to reproduce this and it seems to be fixed.

Let me know if it isn't and how to reproduce.

rndusr avatar Apr 12 '23 13:04 rndusr