Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix file write encoding errors #203

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from

Conversation

LordMartron94
Copy link

@LordMartron94 LordMartron94 commented Jan 10, 2025

You got UnicodeException when writing tables to the log file. This fixes that by explicitly setting the encoding to utf-8.

Also fixes the logger rotation, see commit description.

Drazzilb08 and others added 16 commits November 18, 2024 19:22
In rare cases a container image requires binding a file directly, which the script takes as source_dir for the backup. This adds a check, if the directory the scripts grabs is a filename and strips the filename.

i.e. ./backup_appdata.sh: line 185: cd: /appdata/container/container.conf/..: Not a directory stripes the filename (container.conf), so the script backups /appdata/container/ and its content properly.
…atch-1

Make backup_appdata work if container needs file binds
You got UnicodeException when writing tables to the log file. This fixes that by explicitly setting the encoding to utf-8.
When getting to max logs, you would get an exception where it tries to rename a file into an existing file.

I have fixed this by replacing the entire rotation logic with my own, inspired by my own logging framework in Python. This is proven to work.

⚠️ I have not tested if this works in a Docker configuration. ⚠️
Automatic Jetbrains IDEA Ultimate run to remove unnecessary imports (useful for decluttering)
Apparently my own solution did not work for log files above 9... I worked this out now.
⚠️ Your conf name through rclone has to be "daps" in order for this to work correctly. ⚠️
Apparently the automatic optimization of imports by Jetbrains failed for the first time and deleted some necessary json imports, lol
This is for now better for flow control. Later on I will work on creating a more efficient command executor.

(also added some debug log statements)
That way it doesn't need to iterate over all directories multiple times, I noticed a slow-down here, so I implemented this to prevent that. For now will only work on my machine since I am the only one with such a json file.

Feel free to standardize this into the libraries themselves.
@Drazzilb08 Drazzilb08 changed the base branch from master to dev January 13, 2025 19:42
@Drazzilb08
Copy link
Owner

As there are tons of changes to this and some of them seem custom I'm curious how this work with docker users. Further I'm more inclined to push this to the dev branch for further testing when I get time in which I'm not sure when I'll have that as recently or the past while I've not had time to do much.

@LordMartron94
Copy link
Author

As there are tons of changes to this and some of them seem custom I'm curious how this work with docker users. Further I'm more inclined to push this to the dev branch for further testing when I get time in which I'm not sure when I'll have that as recently or the past while I've not had time to do much.

No worries man. I wrote it primarily for myself and shared in case others find it useful. Feel free to take your time, push it to the dev branch or reject it altogether (:

Glad for all your work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants