Comment 2 for bug 1624661

Phill (phill-ridout) wrote :

This is just a symptom of the actual problem!

Line openlp.core.common.applocation line 84, we assume that a path taken from the settings exists, where as if we are using the default location we actually check that it exists (and create it if we dont)! (openlp.core.common line 65)

openlp.core.common.applocation line 84
    def get_data_path():
        Return the path OpenLP stores all its data under.
        # Check if we have a different data location.
        if Settings().contains('advanced/data path'):
            path = Settings().value('advanced/data path')
            path = AppLocation.get_directory(AppLocation.DataDir)
        return os.path.normpath(path)

openlp.core.common line 65

    def check_directory_exists(directory, do_not_log=False):
        Check a theme directory exists and if not create it

        :param directory: The directory to make sure exists
        :param do_not_log: To not log anything. This is need for the start up, when the log isn't ready.
        if not do_not_log:
            log.debug('check_directory_exists {text}'.format(text=directory))
            if not os.path.exists(directory):
        except IOError as e:
            if not do_not_log:
                log.exception('failed to check if directory exists or create directory')

As we assume that the directory exists when openlp.core.lib.db.init_db line 43 is called, it raises an exception openlp/core/lib/ and the session isn't created.

First part of my prefered solution would be to modify check_directory_exists (openlp.core.common line 65) to return a boolean value indicating if it exists or not.

Then I would make sure that get_data_path (openlp.core.common.applocation line 84) checks that the custom path exists. If the custom path does not exist, the user would be informed (in case of a removable drive, etc.), with an option of resetting the path back to default. If they chose that option then OpenLP could carry on loading (with out the data), or OpenLP would close to allow the user to make the data available (insert removable drive, mount network share etc)