g dZddlZddlZddlZddlZddlmZejeZ edZ dZ dddZ ddd Z dS) u This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.  If not, see . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see Convert serialized scans classes to dicts. In most cases it should be already done in 001_fix_scan_unserialization, but it is still necessary for those who have already updated to 7.1.0 before running 001_fix_scan_unserialization migration. See DEF-24115 for details. N)Pathz$/var/imunify360/aibolit/scans.picklec||jdz}|d5}tj||dddn #1swxYwY||dS)Nz.tempwb) with_namenameopenpickledumpreplace)objpath temp_pathfs a/opt/imunify360/venv/lib/python3.11/site-packages/imav/migrations/002_convert_serialized_scans.pyr r )sty7233I    CdsAAAF)fakec|stsdSdtvr td5}t j|}dddn #1swxYwYt jd|D}t|tdS#t$r,}t dt|Yd}~dSd}~wwxYwdS)Nsimav.malwarelibrbc 3K|]A}|j|j|j|j|j|j|jj|jjdVBdS))r scanid scan_typecreatedstartedargs resource_typestateN) r rrrrrrvaluer).0items r zmigrate..;sn ( (!I"k!%#|#| I%)%7%=!Z-   ( ( ( ( ( (z"Failed to load pickle scans %s: %s) SCANS_PATHexists read_bytesrr load collectionsdequer Exceptionlogger exception)migratorr___rscansupdatedexcs rmigrater02s_ :$$&&Z224444 &&& '! A ' ' ' ' ' ' ' ' ' ' ' ' ' ' '"' ( (" ( ( (  G$ * % % % % %       4j#          %54s;B5A5) B55A99B5<A9=!B55 C+?!C&&C+cdS)N)r*rr+r,s rrollbackr3PsDr )__doc__r% importlibloggingr pathlibr getLogger__name__r(r!r r0r3r2r rr:s:   8 $ $ T8 9 9  %&&&&&<!&       r