Parse-SDK-Flutter icon indicating copy to clipboard operation
Parse-SDK-Flutter copied to clipboard

feat: change the database path for IOS from ApplicationDocumentsDirectory to LibraryDirectory

Open Nidal-Bakir opened this issue 2 years ago • 3 comments

New Pull Request Checklist

  • [x] I am not disclosing a vulnerability.
  • [x] I am creating this PR in reference to an issue.

Issue Description

Related issue: #791

Approach

Using LibraryDirectory as a path for the database.

TODOs before merging

This is a breaking change for ios platform because the SDK now will look for the "parse.db" in the LibraryDirectory rather than the ApplicationDocumentsDirectory.

  • [ ] Add tests
  • [ ] Add changes to documentation (guides, repository pages, in-code descriptions)
  • [ ] A changelog entry

Nidal-Bakir avatar Sep 29 '22 22:09 Nidal-Bakir

Thanks for opening this pull request!

  • ❌ Please link an issue that describes the reason for this pull request, otherwise your pull request will be closed. Make sure to write it as Closes: #123 in the PR description, so I can recognize it.

We can support the old directory path by doing something like:

  Future<String> getDatabaseDirectory() async {
    if (Platform.isIOS) {
      if(await _isDatabaseFileExistsInOldPath()){
        return (await path_provider.getApplicationDocumentsDirectory()).path;
      }
      return (await path_provider.getLibraryDirectory()).path;
    } else {
      return (await path_provider.getApplicationDocumentsDirectory()).path;
    }
  }

  Future<bool> _isDatabaseFileExistsInOldPath() async {
    final oldIosDatabaseDirPath =
        (await path_provider.getApplicationDocumentsDirectory()).path;
    final oldDatabaseFile =
        path.join('$oldIosDatabaseDirPath/parse', 'parse.db');

    if (await File(oldDatabaseFile).exists()) {
      return true;
    }
    return false;
  }

What do you think?

Nidal-Bakir avatar Sep 29 '22 22:09 Nidal-Bakir

@parse-community/flutter-sdk Any suggestion?

mtrezza avatar Sep 29 '22 22:09 mtrezza

@Nidal-Bakir any particular reason for closing this?

mtrezza avatar Oct 23 '22 09:10 mtrezza

@parse-community/flutter-sdk-review should this PR be merged?

mtrezza avatar Oct 23 '22 12:10 mtrezza

It has bee

mtrezza avatar Dec 21 '22 13:12 mtrezza

I will reformat the title to use the proper commit message syntax.

The PR is out of date and it seems the author didn't give the maintainers the option to rebase their PR, so we cannot use this. Could someone open a new PR with these changes?

mtrezza avatar Dec 21 '22 13:12 mtrezza

@mtrezza Sorry for this. I was busy in the past couple of months. I will open a new PR with these changes. and help you guys develop this package. I have free time to work on this project now.

Nidal-Bakir avatar Feb 24 '23 20:02 Nidal-Bakir

Great, looking forward to it

mtrezza avatar Feb 25 '23 10:02 mtrezza