
    1fi                     |    d dl Z d dlZd dlmZ d dlmZ d dlZ ej                  e      Z	 edddd      d	        Z
y)
    N)shared_task)settingsT   <   z-apps.calls.tasks.cleanup_old_recordings_tasks)bindmax_retriesdefault_retry_delaynamec                 j   	 t         j                  j                  t        j                  d      }t        j
                         dz
  }t         j                  j                  |      rt        j                  |      D ]z  }t         j                  j                  ||      }t         j                  j                  |      sCt         j                  j                  |      |k  sft        j                  |       | yy# t        $ r/}t        j                  d|        | j                  |      d}~ww xY w)z4
    Delete call recordings older than 30 days.
    call_recordingsi ' z"Failed to cleanup old recordings: )excN)ospathjoinr   
MEDIA_ROOTtimeexistslistdirisfilegetmtimeremove	Exceptionlogger	exceptionretry)selffoldercutofffilenamefilepathr   s         V/var/www/html/dp2/backend_v2.1/server/apps/calls/tasks/cleanup_old_recordings_tasks.pycleanup_old_recordings_taskr"      s    "h113DE
+77>>&!JJv.77<<977>>(+0@0@0JV0SIIh' / "
  "=cUCDjjSj!!"s$   B;C: >"C: !C: :	D2*D--D2)r   r   celeryr   django.confr   logging	getLogger__name__r   r"        r!   <module>r*      sM    	      
		8	$ 		8	""r)   