Beispiel #1
0
    def remove(self, from_library=False, from_disk=False):
        """Uninstall a game

        Params:
            from_library (bool): Completely remove the game from library, do
                                 not set it as uninstalled
            from_disk (bool): Delete the game files

        Return:
            bool: Updated value for from_library
        """
        if from_disk and self.runner:
            logger.debug("Removing game %s from disk", self.id)
            self.runner.remove_game_data(game_path=self.directory)

        # Do not keep multiple copies of the same game
        existing_games = games_db.get_games_where(slug=self.slug)
        if len(existing_games) > 1:
            from_library = True

        if from_library:
            logger.debug("Removing game %s from library", self.id)
            games_db.delete_game(self.id)
        else:
            games_db.set_uninstalled(self.id)
        if self.config:
            self.config.remove()
        xdgshortcuts.remove_launcher(self.slug, self.id, desktop=True, menu=True)
        self.is_installed = False
        self.emit("game-removed")
        return from_library
Beispiel #2
0
 def test_delete_game(self):
     game_id = games_db.add_game(name="LutrisTest", runner="Linux")
     games_db.delete_game(game_id)
     game_list = games_db.get_games()
     self.assertEqual(len(game_list), 0)
Beispiel #3
0
 def delete(self):
     """Completely remove a game from the library"""
     if self.is_installed:
         raise RuntimeError("Uninstall the game before deleting")
     games_db.delete_game(self.id)
     self.emit("game-removed")