write part file and then replace output file

This commit is contained in:
Fusselkater 2022-11-11 06:41:49 +01:00
parent bf1e3a106a
commit 6c707775a6
1 changed files with 4 additions and 1 deletions

View File

@ -1,4 +1,5 @@
import os
from lib.renderer import Renderer
from PIL import Image, ImageDraw, ImageFont, ImageFile
@ -41,4 +42,6 @@ class PNG_Renderer(Renderer):
draw.text((text_x,artist_y), artist, font=artist_font, fill='#' + self._config['TitleFontColor'])
draw.text((text_x,album_y), album, font=album_font, fill='#' + self._config['TitleFontColor'])
image.save(self._config['OutputPath'])
# Write file and then move it in position
image.save(self._config['OutputPath'] + '.part', 'PNG')
os.replace(self._config['OutputPath'] + '.part', self._config['OutputPath'])