get-got / discord-downloader-go

A Discord bot program to download and otherwise handle files sent in Discord channels with extensive configuration. Can be used as a genuine Discord Bot or user account / self-bot
MIT License
271 stars 30 forks source link

watchSettings not honored? #115

Closed kauffy closed 5 months ago

kauffy commented 7 months ago

I have watchSettings set to true, but it appears that it has no effect; changing the settings file isn't apparently affecting the running application.

get-got commented 7 months ago

I just tested and it works fine for me, could it possibly be due to shortcuts like your other issue?

kauffy commented 7 months ago

To make sure I understand the intended function, any change that I make to the settings.json file should trigger the running program to reread its settings and then operate from the new settings, correct?

In my case, if I make a change to settings, it is reflected in the running application in no way. The settings file is in the same directory as the executable, and neither is shortcuted, so I'm not sure where the disconnect is.

For extra compatibility, I threw out my old settings file and used your new version as a template, and then filled in the appropriate settings.

Nov 30, 2023 17:12:59 DRN @.***>:

I just tested and it works fine for me, could it possibly be due to shortcuts like your other issue?

— Reply to this email directly, view it on GitHub[https://github.com/get-got/discord-downloader-go/issues/115#issuecomment-1835242208], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AAV7HNBMYKXRXFQSU7YMDW3YHEVJFAVCNFSM6AAAAAA74MZF7KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZVGI2DEMRQHA]. You are receiving this because you authored the thread. [Tracking image][https://github.com/notifications/beacon/AAV7HNEDE4VCRVWTWGEW743YHEVJFA5CNFSM6AAAAAA74MZF7KWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTNMOJOA.gif]

get-got commented 7 months ago

You're understanding it correctly. There doesn't even need to be any actual change, the bot simply watches the settings file for any new writes, you can just re-save it and it should trigger immediately, outputting this:

image

What platform are you using? It could be that this utility is windows-specific, I don't remember if I've tried this in linux.

kauffy commented 7 months ago

I am on Windows, yeah. I'm using .json, not .jsonc if that makes a difference. But it does not appear to do what you show from the log. I'll double check tomorrow.

Fletcher Kauffman

Nov 30, 2023 20:03:26 DRN @.***>:

You're understanding it correctly. There doesn't even need to be any actual change, the bot simply watches the settings file for any new writes, you can just re-save it and it should trigger immediately, outputting this:

image.png (view on web)[https://github.com/get-got/discord-downloader-go/assets/43052079/43a45820-3f59-4f70-bd2f-93cc3eb9d182]

What platform are you using? It could be that this utility is windows-specific, I don't remember if I've tried this in linux.

— Reply to this email directly, view it on GitHub[https://github.com/get-got/discord-downloader-go/issues/115#issuecomment-1835421041], or unsubscribe[https://github.com/notifications/unsubscribe-auth/AAV7HNE6I46ZBLJ4L3ZMFP3YHFJIXAVCNFSM6AAAAAA74MZF7KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMZVGQZDCMBUGE]. You are receiving this because you authored the thread. [Tracking image][https://github.com/notifications/beacon/AAV7HNFT5BA5ZXJLJD5EFRDYHFJIXA5CNFSM6AAAAAA74MZF7KWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTNMZGXC.gif]

kauffy commented 7 months ago

I just checked to verify that this is the case, and it definitively does not reload.

get-got commented 7 months ago

Unless you have some weird specific issue, I think I just found what's happening.

I'm assuming by "changing the settings file" in your case, you mean copying/moving a settings.json file from elsewhere into the bot folder, overwriting the existing file that the bot loaded with? If so, that seems to not result in a reload and additionally completely breaks the functionality of the filesystem watcher until reload.

The utility behind watchSettings binds to that specific file at the time of load, not the filepath, because that utility (https://github.com/fsnotify/fsnotify) was made to also track file renaming and deletion for other purposes. So if you replace the original file, it considers the new settings.json a separate file and doesn't watch it. It's only watching for modifications to the existing file that was loaded, so it should update fine if you edit the file in a text editor.

If that's what's happening here, I can add an additional watchSettings option to try and catch it (additional because the solution I have in mind reportedly causes a lot of misfires from certain programs indexing files in the background).

kauffy commented 7 months ago

Well.... I'm not bringing anything in; I'm editing the settings.json in place.

get-got commented 6 months ago

I really have no idea what could be causing this... I haven't had anyone report this before and your environment sounds normal.

What text editor are you using? Maybe it's somehow interfering.

kauffy commented 6 months ago

The editor I'm using is UltraEdit, but it's not doing anything except color-coding it as .json.

The only odd thing I can think of with my environment is that I do not use the standard regional date/time formats for the US, but instead use the European/ISO/sensible formats YYYY-MM-DD and HH:mm. It's possible it's relying on a particular format coming from the system, but my system is not supplying what's expected.

kauffy commented 5 months ago

Just as a reminder, this still doesn't do its thing for me.

get-got commented 5 months ago

I can't fix this if I can't replicate it, I haven't been able to figure out any scenario that causes it to not work for me, it always works. Nobody else has ever reported this issue so I have no idea what to try.

kauffy commented 5 months ago

Well, that triggered a thought, and I investigated it. I have been using UltraEdit, which is a regular ol' text editor except (it appears), it must be saving the original file as the backup (renaming it) and saving to a new file. When I edited in n++, ddg picked it up.

get-got commented 5 months ago

That'll do it. The watchSettings feature binds to the specific file. If it's moved the connection will break even if it's the same path. This seems like a unique issue for that text editor, like I said nobody else has reported and I tried like 4 different editors when you first reported this, they all worked.

kauffy commented 5 months ago

It only occurred to me just now when you described how the process works above-- UE could be doing something weird with the backup file.