Skip to content

Commit

Permalink
fix: download library
Browse files Browse the repository at this point in the history
  • Loading branch information
Sivan22 committed Nov 11, 2024
1 parent a23f05e commit b22fd3d
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 102 deletions.
6 changes: 3 additions & 3 deletions lib/data/data_providers/file_system_data_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,18 @@ class FileSystemData {
if (!Settings.isInitialized) {
await Settings.init(cacheProvider: HiveCache());
}

_updateTitleToPath();
}

/// Returns the library
Future<Library> getLibrary() async {
_updateTitleToPath();
_fetchMetadata();
return _getLibraryFromDirectory(
'${Settings.getValue<String>('key-library-path') ?? '.'}${Platform.pathSeparator}אוצריא');
}

Future<Library> _getLibraryFromDirectory(String path) async {
/// a helper recursive function to get all the categories and books from a directory and its subdirectories
_fetchMetadata();
Category getAllCategoriesAndBooksFromDirectory(
Directory dir, Category? parent) {
Category category = Category(
Expand Down Expand Up @@ -282,6 +281,7 @@ class FileSystemData {

/// Updates the title to path mapping using the provided library path.
void _updateTitleToPath() {
titleToPath = {};
List<String> paths =
getAllBooksPathsFromDirecctory(Settings.getValue('key-library-path'));
for (var path in paths) {
Expand Down
Loading

0 comments on commit b22fd3d

Please sign in to comment.