Various bugfixes and improvements. See angelicadvocate-README.md for details.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
# Enforce LF for all shell scripts and related files
|
||||
*.sh text eol=lf
|
||||
*.bash text eol=lf
|
||||
*.env text eol=lf
|
||||
*.conf text eol=lf
|
||||
Dockerfile text eol=lf
|
||||
*.yml text eol=lf
|
||||
**/run text eol=lf
|
||||
@@ -0,0 +1,26 @@
|
||||
# Development Notes
|
||||
|
||||
## Syntax Fixes
|
||||
- **File:** `hardcover.py` (lines 145 and 147)
|
||||
Changed `is` to `==` when comparing literal values.
|
||||
The original code was using `is` for value comparison, which is meant for identity checks.
|
||||
Using `==` ensures proper value equality checks and avoids `SyntaxWarning` messages in logs.
|
||||
|
||||
## Ingest Filter Fixes
|
||||
- **File:** `ingest_processor.py`
|
||||
Fixed logic for ignoring unwanted files with extensions like `.crdownload`, `.download`, and `.part`.
|
||||
See section: `# Make sure it's a list, if it's a string convert it to a single-item list`.
|
||||
|
||||
## Line Ending Normalization
|
||||
- Added a `.gitattributes` file to enforce LF line endings for shell scripts and related files.
|
||||
This helps prevent inconsistent line endings across environments during versioning, pulls, and merges.
|
||||
|
||||
## Directory Handling
|
||||
- **File:** `metadata-change-detector/run`
|
||||
Added logic to create the `$WATCH_FOLDER` directory if it doesn't exist.
|
||||
This prevents the script from entering a continuous loop due to a missing folder.
|
||||
|
||||
## File Name Truncation
|
||||
- **File:** `ingest_processor.py`
|
||||
Implemented filename truncation to prevent issues with excessively long file names.
|
||||
This resolves errors when processing files that exceed filesystem limits or break internal logic.
|
||||
@@ -142,9 +142,9 @@ class HardcoverClient:
|
||||
"pages": pages_read,
|
||||
"editionId": int(book.get("edition").get("id")),
|
||||
"startedAt":read.get("started_at",datetime.now().strftime("%Y-%m-%d")),
|
||||
"finishedAt": datetime.now().strftime("%Y-%m-%d") if progress_percent is 100 else None
|
||||
"finishedAt": datetime.now().strftime("%Y-%m-%d") if progress_percent == 100 else None
|
||||
}
|
||||
if progress_percent is 100:
|
||||
if progress_percent == 100:
|
||||
self.change_book_status(book, 3)
|
||||
self.execute(query=mutation, variables=variables)
|
||||
return
|
||||
|
||||
@@ -6,6 +6,9 @@ echo "========== STARTING METADATA CHANGE DETECTOR ==========="
|
||||
WATCH_FOLDER="/app/calibre-web-automated/metadata_change_logs"
|
||||
echo "[metadata-change-detector] Watching folder: $WATCH_FOLDER"
|
||||
|
||||
# Create the folder if it doesn't exist
|
||||
mkdir -p "$WATCH_FOLDER"
|
||||
|
||||
# Monitor the folder for new files
|
||||
s6-setuidgid abc inotifywait -m -e close_write -e moved_to --exclude '^.*\.(swp)$' "$WATCH_FOLDER" |
|
||||
while read -r directory events filename; do
|
||||
|
||||
@@ -44,6 +44,10 @@ class NewBookProcessor:
|
||||
self.auto_convert_on = self.cwa_settings['auto_convert']
|
||||
self.target_format = self.cwa_settings['auto_convert_target_format']
|
||||
self.ingest_ignored_formats = self.cwa_settings['auto_ingest_ignored_formats']
|
||||
|
||||
# Make sure it's a list, if it's a string convert it to a single-item list
|
||||
if isinstance(self.ingest_ignored_formats, str):
|
||||
self.ingest_ignored_formats = [self.ingest_ignored_formats]
|
||||
|
||||
# Ignore temporary files during download
|
||||
self.ingest_ignored_formats.append(".crdownload") # Chromium based
|
||||
@@ -233,6 +237,19 @@ class NewBookProcessor:
|
||||
def main(filepath=sys.argv[1]):
|
||||
"""Checks if filepath is a directory. If it is, main will be ran on every file in the given directory
|
||||
Inotifywait won't detect files inside folders if the folder was moved rather than copied"""
|
||||
##############################################################################################
|
||||
# Truncates the filename if it is too long
|
||||
MAX_LENGTH = 150
|
||||
filename = os.path.basename(filepath)
|
||||
name, ext = os.path.splitext(filename)
|
||||
allowed_len = MAX_LENGTH - len(ext)
|
||||
|
||||
if len(name) > allowed_len:
|
||||
new_name = name[:allowed_len] + ext
|
||||
new_path = os.path.join(os.path.dirname(filepath), new_name)
|
||||
os.rename(filepath, new_path)
|
||||
filepath = new_path
|
||||
###############################################################################################
|
||||
if os.path.isdir(filepath) and Path(filepath).exists():
|
||||
# print(os.listdir(filepath))
|
||||
for filename in os.listdir(filepath):
|
||||
|
||||
Reference in New Issue
Block a user