MalloyDelacroix / DownloaderForReddit

The Downloader for Reddit is a GUI application with some advanced features to extract and download submitted content from reddit.
GNU General Public License v3.0
496 stars 47 forks source link

Crash when downloading users #344

Open thany opened 1 year ago

thany commented 1 year ago

Describe the bug When downloading users, whether it be any single user or a whole list, makes the program crash almost instantly.

Environment Information

To Reproduce (optional) Steps to reproduce the behavior:

  1. Not sure
  2. Add loads of users
  3. Download one
  4. See it go poof without error

I cleared the log, made it crash once, and then here be the log: DownloaderForReddit.zip

thany commented 1 year ago

I found a workaround as well, in case anyone else runs into this.

You will need to execute the following SQL statement against DFR's database:

insert into user (id)
select id from reddit_object where id in (
  select reddit_object_id from reddit_object_list_association where reddit_object_list_id=3
)
and id not in (
  select id from user
)

This makes sure that any users in your user list (indicated by reddit_object_list_id=3 in my case - might be a different id for you) exists in the users table.

It seems to me the users table is a bit of an extraneous table, since all it contains is user id's, which are already available elsewhere, and they kind of simply have to exist there. I'm not an expert on this program, but it feels like DFR can be built to not really need this table. However, as of currently, it needs it, and above is just a rudimentary way sort of satisfy the program into having the data there that it (blindly) expects.

MalloyDelacroix commented 1 year ago

Has this happened more than once? It appears that, somehow, a user got into the database without an id, which shouldn't be possible. The ids are auto-incremented by the database.

The user and subreddit tables only contain an id because their SqlAlchemy models inherit from the RedditObject model. All of their data is stored in the reddit_objects table, and only their ids distinguish them as either users or subreddits.

thany commented 1 year ago

It's a one-time thing so far.

Too bad I don't really know how this could've happened. Could be me cocking something up, could be database corruption from an earlier crash maybe, could be a race condition. It's most likely something that's really hard to track down.

But at least there's a workaround. If it happens more oftenly, I should be able to let you know steps to reproduce.