파일 업로드 후 thumb.jpg 까지 같이 삭제하는 문제 수정.

This commit is contained in:
2025-06-30 12:44:52 +09:00
parent a0d7c89617
commit a28c564fca

View File

@ -135,7 +135,7 @@ def write_board(board, subject, content, mb_id, nickname, ca_name=None, file_lis
size, width, height, img_type, now))
file_count += 1
else:
print(f"[경고] 파일 업로드 실패: {file}")
raise Exception(f"[FTP 오류] 파일 업로드 실패: {file}")
curs.execute(f"UPDATE g5_write_{board} SET wr_file = %s WHERE wr_id = %s", (file_count, wr_id))
conn.commit()
@ -143,7 +143,11 @@ def write_board(board, subject, content, mb_id, nickname, ca_name=None, file_lis
except Exception as e:
conn.rollback()
print(f"[DB 오류] {type(e).__name__}: {e}")
if "[FTP 오류]" in str(e):
print(f"[FTP 오류] {e}")
else:
print(f"[DB 오류] {type(e).__name__}: {e}")
raise
finally:
conn.close()
@ -186,6 +190,7 @@ def main():
)
try:
# weather_file만 삭제, thumb.jpg는 삭제하지 않음
if os.path.isfile(weather_file):
os.remove(weather_file)
print(f"[정리 완료] 캡처 이미지 삭제됨: {weather_file}")
@ -193,5 +198,6 @@ def main():
print(f"[삭제 오류] {type(e).__name__}: {e}")
if __name__ == "__main__":
main()