def __update_db_3(db): current_path = Settings.get().path db.create_tables([Storage]) Storage.create(path=current_path, default=True) Settings.update(path="NOT_USED").execute() Settings.update(version=3).execute()
def check_for_tracks(self): """ Check if there are any imported files. If there aren't display a welcome screen. """ if books().count() < 1: path = "" if Storage.select().count() > 0: path = Storage.select().where( Storage.default == True).get().path if not path: path = os.path.join(os.path.expanduser("~"), _("Audiobooks")) if not os.path.exists(path): os.mkdir(path) Storage.create(path=path, default=True) self.no_media_file_chooser.set_current_folder(path) self.main_stack.props.visible_child_name = "no_media" self.block_ui_buttons(True) self.titlebar.stop() self.category_toolbar.set_visible(False) else: self.main_stack.props.visible_child_name = "main" # This displays the placeholder if there is not a recent book yet self.__on_sort_stack_changed(None, None)
def __on_no_media_folder_changed(self, sender): """ Get's called when the user changes the audiobook location from the no media screen. Now we want to do a first scan instead of a rebase. """ location = self.no_media_file_chooser.get_file().get_path() external = self.external_switch.get_active() Storage.delete().where(Storage.path != "").execute() Storage.create(path=location, default=True, external=external) self.main_stack.props.visible_child_name = "import" self.scan(None, True) self.settings._init_storage() self.fs_monitor.init_offline_mode()
def __on_add_storage_clicked(self, widget): """ Add a new storage selector to the ui. """ db_obj = Storage.create(path="") self.storage_list_box.add( StorageListBoxRow(self, db_obj.id, "", False, False))