(self, force=False)
Restore container files after FileBind
Restore container files after FileBind
Restore container files after FileBind
def restore(self, force=False):
        """Restore container files after FileBind"""
        error = False
        if not os.path.isdir(self.container_orig_dir):
            return
        for f_name in os.listdir(self.container_orig_dir):
            orig_file = self.container_orig_dir + '/' + f_name
            if not os.path.isfile(orig_file):
                continue
            cont_file = os.path.basename(f_name).replace('#', '/')
            cont_file = self.container_root + '/' + cont_file
            if os.path.islink(cont_file):
                FileUtil(cont_file).register_prefix()
                FileUtil(cont_file).remove()
            elif os.path.exists(cont_file):
                continue
            if not FileUtil(orig_file).rename(cont_file):
                Msg().err("Error: restoring binded file:", cont_file)
                error = True
        if not error or force:
            FileUtil(self.container_orig_dir).remove(recursive=True)
        FileUtil(self.container_bind_dir).remove(recursive=True)
def restore ( self , force = False ) : error = False if not os . path . isdir ( self . container_orig_dir ) : return for f_name in os . listdir ( self . container_orig_dir ) : orig_file = self . container_orig_dir + '/' + f_name if not os . path . isfile ( orig_file ) : continue cont_file = os . path . basename ( f_name ) . replace ( '#' , '/' ) cont_file = self . container_root + '/' + cont_file if os . path . islink ( cont_file ) : FileUtil ( cont_file ) . register_prefix ( ) FileUtil ( cont_file ) . remove ( ) elif os . path . exists ( cont_file ) : continue if not FileUtil ( orig_file ) . rename ( cont_file ) : Msg ( ) . err ( "Error: restoring binded file:" , cont_file ) error = True if not error or force : FileUtil ( self . container_orig_dir ) . remove ( recursive = True ) FileUtil ( self . container_bind_dir ) . remove ( recursive = True )