lay295 / TwitchDownloader

Twitch VOD/Clip Downloader - Chat Download/Render/Replay
MIT License
2.51k stars 257 forks source link

chatdownload failure results in zero-length file #1099

Closed glubsy closed 2 weeks ago

glubsy commented 2 weeks ago

Checklist

Edition

Command Line Interface

Describe your issue here

Since 1.54.4, if a chatdownload command fails (due to video Id not found), an empty output file is left in the file system.

Example:

> TwitchDownloaderCLI_1.54.4 chatdownload --id "51277891293" -E -o 51277891293.json
 ---> System.NullReferenceException: Invalid VOD, deleted/expired VOD possibly? 
[...]
zsh: abort      /opt/TwitchDownloaderCLI_1.54.4 chatdownload --id  -E -

> ls -alh
-rw-r--r-- 1 user group     0 2024-06-16 12:25  51277891293.json 

This also happens with any of the --collision flags. Also happens with 1.54.5. This did not happen before (ie. 1.54.3).

Expected behaviour:

The output JSON file should not be created.

Add any related files or extra information here

Here is a VOD Id that does not exist: 51277891293

ScrubN commented 2 weeks ago

This is a byproduct of creating the output file immediately to protect against possible file collisions. It is present in all modes.

ScrubN commented 2 weeks ago

As I was typing out a longer response defense of my laziness, I thought of a somewhat uncomplicated solution to this problem. I'll see about implementing it for 1.54.6.