Debug for attached media

main
bashrc 2026-05-07 15:01:25 +01:00
parent dd111e35c0
commit 05b8cc401a
4 changed files with 20 additions and 5 deletions

View File

@ -76,10 +76,10 @@ def receive_image_attachment(self, length: int, path: str, base_dir: str,
if debug: if debug:
if is_a_file(media_filename): if is_a_file(media_filename):
file_size: int = os.path.getsize(media_filename) file_size: int = os.path.getsize(media_filename)
print('DEBUG: image saved to ' + media_filename + ' ' + print('DEBUG: uploaded image saved to ' + media_filename + ' ' +
str(file_size) + ' bytes') str(file_size) + ' bytes')
else: else:
print('WARN: image not saved ' + media_filename) print('WARN: uploaded image not saved ' + media_filename)
self.send_response(201) self.send_response(201)
self.end_headers() self.end_headers()
self.server.postreq_busy = False self.server.postreq_busy = False

View File

@ -1911,7 +1911,8 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
if file_size_watermark < file_size_original / 2: if file_size_watermark < file_size_original / 2:
# if the file size is too small then this indicates # if the file size is too small then this indicates
# that watermarking failed # that watermarking failed
print('WARN: watermark failed, restoring backup') print('WARN: watermark failed, restoring backup ' +
filename)
erase_file(filename, erase_file(filename,
'EX: failed to erase watermarked file ' + 'EX: failed to erase watermarked file ' +
filename) filename)
@ -1935,7 +1936,7 @@ def _receive_new_post_process(self, post_type: str, path: str, headers: {},
# if the file size is too small then this indicates # if the file size is too small then this indicates
# that metadata removal failed # that metadata removal failed
print('WARN: image metadata removal failed, ' + print('WARN: image metadata removal failed, ' +
'restoring backup') 'restoring backup ' + post_image_filename)
erase_file(filename, 'EX: ' + erase_file(filename, 'EX: ' +
'failed to erase metadata processed image ' + 'failed to erase metadata processed image ' +
post_image_filename) post_image_filename)

View File

@ -754,9 +754,23 @@ def attach_media(base_dir: str, http_prefix: str,
if low_bandwidth: if low_bandwidth:
convert_image_to_low_bandwidth(image_filename) convert_image_to_low_bandwidth(image_filename)
exif_json: list[dict] = [] exif_json: list[dict] = []
file_size_original: int = os.path.getsize(image_filename)
# TODO add watermark?
process_meta_data(base_dir, nickname, domain, process_meta_data(base_dir, nickname, domain,
image_filename, media_filename, city, image_filename, media_filename, city,
content_license_url, exif_json, debug) content_license_url, exif_json, debug)
file_size_meta_data: int = os.path.getsize(media_filename)
if debug:
print('DEBUG: attach_media ' +
'image size before metadata removal ' +
str(file_size_original) + ' and after ' +
str(file_size_meta_data))
if file_size_meta_data < file_size_original / 2:
# if the file size is too small then this indicates
# that metadata removal failed
print('WARN: attach_media image metadata removal failed ' +
media_filename)
copyfile(image_filename, media_filename)
if exif_json: if exif_json:
# FEP-ee3a # FEP-ee3a
# https://codeberg.org/fediverse/fep/src/branch/main/ # https://codeberg.org/fediverse/fep/src/branch/main/

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
journalctl -u epicyon | grep 'image binary\|favicon is not an image\|image size before\|watermark failed\|image metadata removal\|media saved to\|failed to restore backup image\|failed to rename image\|media could not be saved to\|failed to delete backup image\|post_message_to_outbox unable to rename\|rename image upload' > .image.txt journalctl -u epicyon | grep 'image binary\|favicon is not an image\|image size before\|watermark failed\|image metadata removal\|media saved to\|failed to restore backup image\|failed to rename image\|media could not be saved to\|failed to delete backup image\|post_message_to_outbox unable to rename\|rename image upload\|uploaded image saved to\|uploaded image not saved' > .image.txt
if [ ! -f .image.txt ]; then if [ ! -f .image.txt ]; then
echo 'No image warnings' echo 'No image warnings'
else else