Skip to content

Commit

Permalink
Fix switching data directory not working
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeDoctorDE committed Oct 6, 2024
1 parent 6ef14c1 commit b94d113
Show file tree
Hide file tree
Showing 7 changed files with 118 additions and 164 deletions.
18 changes: 9 additions & 9 deletions app/android/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GEM
artifactory (3.0.17)
atomos (0.1.3)
aws-eventstream (1.3.0)
aws-partitions (1.981.0)
aws-partitions (1.985.0)
aws-sdk-core (3.209.1)
aws-eventstream (~> 1, >= 1.3.0)
aws-partitions (~> 1, >= 1.651.0)
Expand All @@ -19,7 +19,7 @@ GEM
aws-sdk-kms (1.94.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sigv4 (~> 1.5)
aws-sdk-s3 (1.166.0)
aws-sdk-s3 (1.167.0)
aws-sdk-core (~> 3, >= 3.207.0)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.5)
Expand All @@ -38,7 +38,7 @@ GEM
domain_name (0.6.20240107)
dotenv (2.8.1)
emoji_regex (3.2.3)
excon (0.111.0)
excon (0.112.0)
faraday (1.10.4)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
Expand Down Expand Up @@ -128,7 +128,7 @@ GEM
google-cloud-core (1.7.1)
google-cloud-env (>= 1.0, < 3.a)
google-cloud-errors (~> 1.0)
google-cloud-env (2.2.0)
google-cloud-env (2.2.1)
faraday (>= 1.0, < 3.a)
google-cloud-errors (1.4.0)
google-cloud-storage (1.52.0)
Expand All @@ -140,7 +140,7 @@ GEM
google-cloud-core (~> 1.6)
googleauth (~> 1.9)
mini_mime (~> 1.0)
googleauth (1.11.0)
googleauth (1.11.1)
faraday (>= 1.0, < 3.a)
google-cloud-env (~> 2.1)
jwt (>= 1.4, < 3.0)
Expand All @@ -153,7 +153,7 @@ GEM
httpclient (2.8.3)
jmespath (1.6.2)
json (2.7.2)
jwt (2.9.1)
jwt (2.9.3)
base64
mini_magick (4.13.2)
mini_mime (1.1.5)
Expand Down Expand Up @@ -199,13 +199,13 @@ GEM
uber (0.1.0)
unicode-display_width (2.6.0)
word_wrap (1.0.0)
xcodeproj (1.25.0)
xcodeproj (1.25.1)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (>= 3.3.2, < 4.0)
rexml (>= 3.3.6, < 4.0)
xcpretty (0.3.0)
rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.1)
Expand All @@ -222,4 +222,4 @@ DEPENDENCIES
screengrab

BUNDLED WITH
2.5.20
2.5.21
12 changes: 7 additions & 5 deletions app/lib/api/file_system.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ const butterflySubDirectory = '/Linwood/Butterfly';

String? overrideButterflyDirectory;

Future<String> getButterflyDirectory({bool root = false}) async {
Future<String> getButterflyDirectory({bool usePrefs = true}) async {
var directory = overrideButterflyDirectory;
if (directory != null) return directory;
var prefs = await SharedPreferences.getInstance();
String? path;
if (prefs.containsKey('document_path')) {
path = prefs.getString('document_path');
if (usePrefs) {
final prefs = await SharedPreferences.getInstance();
if (prefs.containsKey('document_path')) {
path = prefs.getString('document_path');
}
}
if (path == '') {
path = null;
Expand All @@ -40,7 +42,7 @@ Future<String> getButterflyDirectory({bool root = false}) async {
path ??= (await getExternalStorageDirectory())?.path;
}
path ??= (await getApplicationDocumentsDirectory()).path;
if (!root) path += butterflySubDirectory;
path += butterflySubDirectory;
return path;
}

Expand Down
15 changes: 12 additions & 3 deletions app/lib/settings/data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class _DataSettingsPageState extends State<DataSettingsPage> {
const PhosphorIcon(PhosphorIconsLight.folder),
subtitle: state.documentPath.isNotEmpty
? FutureBuilder<String>(
future: getButterflyDirectory(root: true),
future: getButterflyDirectory(),
builder: (context, snapshot) {
if (snapshot.hasData) {
return Text(snapshot.data!);
Expand Down Expand Up @@ -166,8 +166,17 @@ class _DataSettingsPageState extends State<DataSettingsPage> {
}

Future<void> _changePath(SettingsCubit settingsCubit, String newPath) async {
final oldPath = settingsCubit.state.documentPath;
if (!(await _documentSystem.moveAbsolute(oldPath, newPath))) {
var oldPath = settingsCubit.state.documentPath;
final defaultPath = await getButterflyDirectory(usePrefs: false);
if (oldPath.isEmpty) {
oldPath = defaultPath;
}
var movedPath = newPath;
if (movedPath.isEmpty) {
movedPath = defaultPath;
}
if (!(await _documentSystem.moveAbsolute(oldPath, movedPath)) &&
newPath.isNotEmpty) {
return;
}
settingsCubit.changeDocumentPath(newPath);
Expand Down
52 changes: 26 additions & 26 deletions app/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,10 @@ packages:
dependency: transitive
description:
name: camera_android_camerax
sha256: "803e45c406de922bd107199089be3f3d5ae7ab0a1ff119a27a0062325541c50e"
sha256: "59a01443c280cf969449f4b72db9396e80e5a9e8f07a2500a042906a157ce894"
url: "https://pub.dev"
source: hosted
version: "0.6.9"
version: "0.6.9+2"
camera_avfoundation:
dependency: transitive
description:
Expand Down Expand Up @@ -378,10 +378,10 @@ packages:
dependency: "direct dev"
description:
name: espresso
sha256: ceb78974a79f266c9acc13c476e84e877ee320cadff857d9c3fbc425d27a46d4
sha256: cbf1b4c38c9a60ec77a2b24346155918141b15bca92f308c0246e76cdf43450b
url: "https://pub.dev"
source: hosted
version: "0.4.0+1"
version: "0.4.0+3"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -418,18 +418,18 @@ packages:
dependency: transitive
description:
name: file_selector_android
sha256: b8c9717a0177ca6fa035554b82cd6c83b838ddc66b7704eb6df0f77f027ecc90
sha256: "00aafa9ae05a8663d0b4f17abd2a02316911ca0f46f9b9dacb9578b324d99590"
url: "https://pub.dev"
source: hosted
version: "0.5.1+7"
version: "0.5.1+9"
file_selector_ios:
dependency: transitive
description:
name: file_selector_ios
sha256: "38ebf91ecbcfa89a9639a0854ccaed8ab370c75678938eebca7d34184296f0bb"
sha256: "94b98ad950b8d40d96fee8fa88640c2e4bd8afcdd4817993bd04e20310f45420"
url: "https://pub.dev"
source: hosted
version: "0.5.3"
version: "0.5.3+1"
file_selector_linux:
dependency: transitive
description:
Expand All @@ -442,10 +442,10 @@ packages:
dependency: transitive
description:
name: file_selector_macos
sha256: cb284e267f8e2a45a904b5c094d2ba51d0aabfc20b1538ab786d9ef7dc2bf75c
sha256: "271ab9986df0c135d45c3cdb6bd0faa5db6f4976d3e4b437cf7d0f258d941bfc"
url: "https://pub.dev"
source: hosted
version: "0.9.4+1"
version: "0.9.4+2"
file_selector_platform_interface:
dependency: transitive
description:
Expand Down Expand Up @@ -546,10 +546,10 @@ packages:
dependency: transitive
description:
name: flutter_plugin_android_lifecycle
sha256: "9ee02950848f61c4129af3d6ec84a1cfc0e47931abc746b03e7a3bc3e8ff6eda"
sha256: "9b78450b89f059e96c9ebb355fa6b3df1d6b330436e0b885fb49594c41721398"
url: "https://pub.dev"
source: hosted
version: "2.0.22"
version: "2.0.23"
flutter_secure_storage:
dependency: "direct main"
description:
Expand Down Expand Up @@ -658,10 +658,10 @@ packages:
dependency: "direct main"
description:
name: go_router
sha256: "5cf5fdcf853b0629deb35891c7af643be900c3dcaed7489009f9e7dbcfe55ab6"
sha256: "6f1b756f6e863259a99135ff3c95026c3cdca17d10ebef2bba2261a25ddc8bbc"
url: "https://pub.dev"
source: hosted
version: "14.2.8"
version: "14.3.0"
graphs:
dependency: transitive
description:
Expand Down Expand Up @@ -997,10 +997,10 @@ packages:
dependency: transitive
description:
name: path_provider_android
sha256: "6f01f8e37ec30b07bc424b4deabac37cacb1bc7e2e515ad74486039918a37eb7"
sha256: f7544c346a0742aee1450f9e5c0f5269d7c602b9c95fdbcd9fb8f5b1df13b1cc
url: "https://pub.dev"
source: hosted
version: "2.2.10"
version: "2.2.11"
path_provider_foundation:
dependency: transitive
description:
Expand Down Expand Up @@ -1198,10 +1198,10 @@ packages:
dependency: transitive
description:
name: sembast
sha256: "934a7b99297fb4f0b6e69fb1465286737b3b47b1a5149bf8dfc85667fbbdd21d"
sha256: dc42f8384edc2bc0c11c90856fa62630ad2a75d8a37c786e000517bd8298682d
url: "https://pub.dev"
source: hosted
version: "3.7.4+3"
version: "3.7.5"
share_plus:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1230,18 +1230,18 @@ packages:
dependency: transitive
description:
name: shared_preferences_android
sha256: "480ba4345773f56acda9abf5f50bd966f581dac5d514e5fc4a18c62976bbba7e"
sha256: "3b9febd815c9ca29c9e3520d50ec32f49157711e143b7a4ca039eb87e8ade5ab"
url: "https://pub.dev"
source: hosted
version: "2.3.2"
version: "2.3.3"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: c4b35f6cb8f63c147312c054ce7c2254c8066745125264f0c88739c417fc9d9f
sha256: "07e050c7cd39bad516f8d64c455f04508d09df104be326d8c02551590a0d513d"
url: "https://pub.dev"
source: hosted
version: "2.5.2"
version: "2.5.3"
shared_preferences_linux:
dependency: transitive
description:
Expand Down Expand Up @@ -1451,10 +1451,10 @@ packages:
dependency: transitive
description:
name: url_launcher_android
sha256: e35a698ac302dd68e41f73250bd9517fe3ab5fa4f18fe4647a0872db61bacbab
sha256: "8fc3bae0b68c02c47c5c86fa8bfa74471d42687b0eded01b78de87872db745e2"
url: "https://pub.dev"
source: hosted
version: "6.3.10"
version: "6.3.12"
url_launcher_ios:
dependency: transitive
description:
Expand Down Expand Up @@ -1619,10 +1619,10 @@ packages:
dependency: transitive
description:
name: xdg_directories
sha256: faea9dee56b520b55a566385b84f2e8de55e7496104adada9962e0bd11bcff1d
sha256: "7a3f37b05d989967cdddcbb571f1ea834867ae2faa29725fd085180e0883aa15"
url: "https://pub.dev"
source: hosted
version: "1.0.4"
version: "1.1.0"
xml:
dependency: "direct main"
description:
Expand Down
4 changes: 2 additions & 2 deletions docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/check": "^0.9.3",
"@astrojs/check": "^0.9.4",
"@astrojs/react": "^3.6.2",
"@astrojs/starlight": "^0.28.2",
"@phosphor-icons/react": "^2.1.7",
Expand All @@ -24,7 +24,7 @@
"sharp": "^0.33.5",
"typescript": "^5.6.2"
},
"packageManager": "pnpm@9.11.0",
"packageManager": "pnpm@9.12.0",
"devDependencies": {
"sass": "^1.79.4"
}
Expand Down
Loading

0 comments on commit b94d113

Please sign in to comment.