파일 업로드 후 thumb.jpg 까지 같이 삭제하는 문제 수정.
This commit is contained in:
@ -135,7 +135,7 @@ def write_board(board, subject, content, mb_id, nickname, ca_name=None, file_lis
|
|||||||
size, width, height, img_type, now))
|
size, width, height, img_type, now))
|
||||||
file_count += 1
|
file_count += 1
|
||||||
else:
|
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))
|
curs.execute(f"UPDATE g5_write_{board} SET wr_file = %s WHERE wr_id = %s", (file_count, wr_id))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@ -143,7 +143,11 @@ def write_board(board, subject, content, mb_id, nickname, ca_name=None, file_lis
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
conn.rollback()
|
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:
|
finally:
|
||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
@ -186,6 +190,7 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# weather_file만 삭제, thumb.jpg는 삭제하지 않음
|
||||||
if os.path.isfile(weather_file):
|
if os.path.isfile(weather_file):
|
||||||
os.remove(weather_file)
|
os.remove(weather_file)
|
||||||
print(f"[정리 완료] 캡처 이미지 삭제됨: {weather_file}")
|
print(f"[정리 완료] 캡처 이미지 삭제됨: {weather_file}")
|
||||||
@ -193,5 +198,6 @@ def main():
|
|||||||
print(f"[삭제 오류] {type(e).__name__}: {e}")
|
print(f"[삭제 오류] {type(e).__name__}: {e}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|||||||
Reference in New Issue
Block a user