View Single Post
Old 04-28-2019, 05:19 PM   #1208
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,017
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
I haven't been paying much attention to who's maintaining this one lately, but I found a bug in the plugin while working on a private project.

_remove_files_if_exist(), used for 'Remove iTunes files', 'Remove calibre bookmark files' and 'Remove OS artifact files' will only remove the first file found from each list.

Here's a fixed version that removes them all as (I assume) it should work. The change is the addition of a dirtied flag instead of returning immediately on file remove.
Code:
    def _remove_files_if_exist(self, container, files):
        '''
        Helper function to remove items from manifest whose filename is
        in the set of 'files'
        '''
        dirtied = False
        self.log('\tLooking for files to remove:', files)
        files = [f.lower() for f in files]
        for name in list(container.name_path_map.keys()):
            found = False
            if name.lower() in files:
                found = True
            if not found:
                for f in files:
                    if name.lower().endswith('/'+f):
                        found = True
                        break
            if found:
                self.log('\t  Found file to remove:', name)
                container.delete_from_manifest(name)
                dirtied = True
        return dirtied
JimmXinu is offline   Reply With Quote