fix: アルトマークファイルのバックアップタイミングを修正

This commit is contained in:
shimoda.m@nds-tyo.co.jp 2023-05-15 13:40:05 +09:00
parent 75dfa77d78
commit b73f467184
2 changed files with 5 additions and 8 deletions

View File

@ -68,11 +68,11 @@ class UltmarcBucket(S3Bucket):
return temporary_file_path
def backup_dat_file(self, dat_file_key: str, datetime_key: str):
# バックアップバケットにコピー
ultmarc_backup_bucket = UltmarcBackupBucket()
backup_key = f'{ultmarc_backup_bucket._folder}/{datetime_key}/{dat_file_key.replace(f"{self._folder}/", "")}'
self._s3_client.copy(self._bucket_name, dat_file_key, ultmarc_backup_bucket._bucket_name, backup_key)
def delete_dat_file(self, dat_file_key: str):
# コピー元のファイルを削除
self._s3_client.delete_file(self._bucket_name, dat_file_key)

View File

@ -45,17 +45,14 @@ def exec_import():
dat_file_name = dat_file_info['filename']
logger.info(f"{dat_file_name}を取り込みます")
# ファイルをバックアップ
# 現行は、jobctrl_dailyの先頭でやっている
ultmarc_bucket.backup_dat_file(dat_file_name, batch_context.syor_date)
# datファイルをダウンロード
local_file_path = ultmarc_bucket.download_dat_file(dat_file_name)
dat_file = DatFile.from_path(local_file_path)
# アルトマーク取り込み実行
_import_to_ultmarc_table(dat_file)
# 処理後、ファイルをS3から削除する
logger.info(f'取り込み処理が完了したため、datファイルを削除。ファイル名={dat_file_name}')
ultmarc_bucket.delete_dat_file(dat_file_name)
# 処理後ファイルをバックアップ
ultmarc_bucket.backup_dat_file(dat_file_name, batch_context.syor_date)
logger.info(f'取り込み処理が完了したため、datファイルをバックアップ。ファイル名={dat_file_name}')
# アルトマーク取込済をマーク
batch_context.is_ultmarc_imported = True
logger.info('アルトマーク取込処理: 終了')