def delete_cache_folder(): # Delete cache folder in the add-on userdata (no more needed with the new cache management) cache_path = os.path.join(g.DATA_PATH, 'cache') if not os.path.exists(g.py2_decode(xbmc.translatePath(cache_path))): return debug('Deleting the cache folder from add-on userdata folder') try: delete_folder_contents(cache_path, True) xbmc.sleep(80) xbmcvfs.rmdir(cache_path) except Exception: # pylint: disable=broad-except import traceback error(traceback.format_exc())
def clear_library(self, show_prg_dialog=True): """ Delete all exported items to the library :param show_prg_dialog: if True, will be show a progress dialog window """ LOG.info('Start deleting exported library items') # This will clear all the add-on library data, to prevents possible inconsistencies when for some reason # such as improper use of the add-on, unexpected error or other has broken the library database data or files with ui.ProgressDialog(show_prg_dialog, common.get_local_string(30245), max_value=3) as progress_dlg: progress_dlg.perform_step() progress_dlg.set_wait_message() G.SHARED_DB.purge_library() for folder_name in [FOLDER_NAME_MOVIES, FOLDER_NAME_SHOWS]: progress_dlg.perform_step() progress_dlg.set_wait_message() section_root_dir = common.join_folders_paths(get_library_path(), folder_name) common.delete_folder_contents(section_root_dir, delete_subfolders=True) # Clean the Kodi library database common.clean_library(show_prg_dialog)
def purge(): """Purge all items exported to Kodi library and delete internal library database""" common.info('Purging internal database and kodi library') for videoid_value in g.SHARED_DB.get_movies_id_list(): videoid = common.VideoId.from_path( [common.VideoId.MOVIE, videoid_value]) execute_library_tasks(videoid, [remove_item], common.get_local_string(30030)) for videoid_value in g.SHARED_DB.get_tvshows_id_list(): videoid = common.VideoId.from_path( [common.VideoId.SHOW, videoid_value]) execute_library_tasks(videoid, [remove_item], common.get_local_string(30030)) # If for some reason such as improper use of the add-on, unexpected error or other # has caused inconsistencies with the contents of the database or stored files, # make sure that everything is removed g.SHARED_DB.purge_library() for folder_name in [FOLDER_MOVIES, FOLDER_TV]: section_dir = xbmc.translatePath( xbmc.makeLegalFilename('/'.join([library_path(), folder_name]))) common.delete_folder_contents(section_dir, delete_subfolders=True)
def _invalidate_on_disk(self, bucket_names): for bucket in bucket_names: common.delete_folder_contents(os.path.join(self.cache_path, bucket))