Show
Ignore:
Timestamp:
04/27/09 22:10:31 (17 months ago)
Author:
Diego Búrigo Zacarão <diegobz@…>
Branch:
default
Message:

Delete cache and POFiles entries when a file is deleted from upstream

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • projects/handlers/types/pot.py

    r514 r528  
    11from translations.lib.types.pot import POTManager 
     2from translations.models import POFile 
    23from txcommon.log import logger 
    34 
     
    5758            self.set_stats_for_lang(lang) 
    5859 
     60        self.clear_old_stats() 
     61 
     62    def clear_old_stats(self): 
     63        """ 
     64        Clear stats present on the database and msgmerge dir, that are not  
     65        anymore in the upstream repository 
     66        """ 
     67        pofiles = POFile.objects.select_related().filter( 
     68            component=self.component) 
     69        pots = self.tm.get_source_files() 
     70        files = self.tm.get_po_files() 
     71        for pot in pots: 
     72            files.append(pot) 
     73        logger.info(files) 
     74        for stat in pofiles: 
     75            if stat.filename not in files: 
     76                self.tm.delete_file_from_static_dir(stat.filename) 
     77                stat.delete() 
     78 
    5979    def clear_stats(self): 
    6080        """Clear stats for all translations of the component."""